servlet3.0的文件上传代码配置怎么写 标签: 原文地址:https://www.cnblogs.com/woy
之前学习过xml配置servlet3.0的文件上传,但是酿成code方法一直不知道怎么弄,对对照起来apache的文件上传配置和xml却是没什么太大区别。
直接上代码:无需依赖,只要一个要领就好了customizeRegistration()
public class SystemConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[]{SsmConfig.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[0];
}
@Override
protected String[] getServletMappings() {
return new String[]{"http://www.mamicode.com/"};
}
// ""中不需要写什么,后面三个参数可以进入源代码看一下,至于数值最好还是写大点,之前写小了,连个20kb的图片都传不了
// 固然,我只是代码测试,所以数值不所谓,你要是其他的话还是规范点数值对照好
@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
registration.setMultipartConfig(new MultipartConfigElement("",
20000000, 20000000, 0));
}
}
只需要写customizeRegisteration()这个要领就可以了,实际上servlet3.0无论是xml还是code方法都是可以不用解析器的,但是你写了也没题,这个我本身测试过。
servlet3.0的文件上传代码配置怎么写
标签:
原文地点:https://www.cnblogs.com/woyujiezhen/p/12106601.html
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/32917.html
- 上一篇:cli上引入插件JQUERY
- 下一篇:phpMyAdmin跳过登陆