List of usage examples for javax.servlet MultipartConfigElement MultipartConfigElement
public MultipartConfigElement(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold)
From source file:com.contact.MyWebAppInitializer.java
public void onStartup(ServletContext container) throws ServletException { XmlWebApplicationContext appContext = new XmlWebApplicationContext(); appContext.setConfigLocation("/WEB-INF/spring/appServlet/servlet-context.xml"); ServletRegistration.Dynamic dispatcher = container.addServlet("appServlet", new DispatcherServlet(appContext)); MultipartConfigElement multipartConfigElement = new MultipartConfigElement(null, 5000000, 5000000, 0); dispatcher.setMultipartConfig(multipartConfigElement); dispatcher.setLoadOnStartup(1);//w w w. j av a 2s .c om dispatcher.addMapping("/"); }
From source file:org.fon.documentmanagementsystem.config.WebAppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(AppConfig.class); ctx.setServletContext(servletContext); ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1);// w ww .java2s.co m servlet.setMultipartConfig(new MultipartConfigElement("", 1024 * 1024 * 25, 1024 * 1024 * 25, 0)); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); }
From source file:rzd.vivc.documentexamination.configuration.initilizer.WebAppInitializer.java
@Override // ? ?/*ww w .j av a 2 s. c o m*/ protected void customizeRegistration(ServletRegistration.Dynamic registration) { super.customizeRegistration(registration); // //? //v? ? ? //? , ? ?, . ?? ? ? ? registration.setMultipartConfig(new MultipartConfigElement("C:" + File.separator + File.separator + "temp", 209715200, 419430400, 0)); }
From source file:magoffin.matt.sobriquet.web.config.WebAppInitializer.java
@Override protected void customizeRegistration(ServletRegistration.Dynamic registration) { registration.setMultipartConfig(/*from www.j a va 2s . com*/ new MultipartConfigElement(null, 1024 * 1024 * 5, 1024 * 1024 * 5 * 5, 1024 * 1024)); }
From source file:com.github.cherimojava.orchidae.Starter.java
private ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException { ServletContextHandler servletContext = new ServletContextHandler(); servletContext.addEventListener(new ContextLoaderListener(context)); ServletHolder holder = new ServletHolder("default", new DispatcherServlet(context)); holder.getRegistration()//from w ww . j ava 2 s .c om .setMultipartConfig(new MultipartConfigElement("./tmp", 20000000, 20000000, 200000)); servletContext.addServlet(holder, "/*"); servletContext.addEventListener(new ServletListener(context)); servletContext.setResourceBase(new FileSystemResource(new File("./")).toString()); servletContext.setSessionHandler(new SessionHandler()); return servletContext; }
From source file:com.qwazr.server.ServletContextBuilder.java
public ServletContextBuilder setDefaultMultipartConfig(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold) { return setDefaultMultipartConfig(new MultipartConfigElement( StringUtils.isEmpty(location) ? SystemUtils.getJavaIoTmpDir().getAbsolutePath() : location, maxFileSize, maxRequestSize, fileSizeThreshold)); }
From source file:org.unidle.config.DispatcherServletInitializer.java
@Override protected void customizeRegistration(final Dynamic registration) { registration.setMultipartConfig(/*from www.j a va2 s .c o m*/ new MultipartConfigElement(LOCATION, MAX_FILE_SIZE, MAX_REQUEST_SIZE, FILE_SIZE_THRESHOLD)); }
From source file:com.iflytek.edu.cloud.frame.web.RestServiceWebApplicationInitializer.java
private MultipartConfigElement getMultiPartConfig() { String location = System.getProperty("java.io.tmpdir"); long maxFileSize = -1; long maxRequestSize = -1; int fileSizeThreshold = -1; return new MultipartConfigElement(location, maxFileSize, maxRequestSize, fileSizeThreshold); }
From source file:com.qwazr.server.ServletContextBuilder.java
public ServletContextBuilder servlet(final String name, final Class<? extends Servlet> servletClass, final GenericFactory instanceFactory, final String... urlPatterns) { final ServletInfo servletInfo; // WebServlet annotation final WebServlet webServlet = AnnotationsUtils.getFirstAnnotation(servletClass, WebServlet.class); if (webServlet != null) { servletInfo = servletInfo(StringUtils.isEmpty(name) ? webServlet.name() : name, servletClass, instanceFactory);// ww w . j a va2 s . c om servletInfo.setLoadOnStartup(webServlet.loadOnStartup()); servletInfo.setAsyncSupported(webServlet.asyncSupported()); servletInfo.addMappings(webServlet.value()); servletInfo.addMappings(webServlet.urlPatterns()); for (WebInitParam webInitParam : webServlet.initParams()) servletInfo.addInitParam(webInitParam.name(), webInitParam.value()); } else servletInfo = servletInfo(StringUtils.isEmpty(name) ? servletClass.getName() : name, servletClass, instanceFactory); if (urlPatterns != null && urlPatterns.length > 0) servletInfo.addMappings(urlPatterns); // ServletSecurity final ServletSecurity servletSecurity = AnnotationsUtils.getFirstAnnotation(servletClass, ServletSecurity.class); if (servletSecurity != null) { final ServletSecurityInfo servletSecurityInfo = new ServletSecurityInfo(); // HttpConstraint final HttpConstraint httpConstraint = servletSecurity.value(); servletSecurityInfo.setEmptyRoleSemantic(get(httpConstraint.value())); servletSecurityInfo.addRolesAllowed(httpConstraint.rolesAllowed()); servletSecurityInfo.setTransportGuaranteeType(get(httpConstraint.transportGuarantee())); // HttpMethodConstraints for (final HttpMethodConstraint httpMethodConstraints : servletSecurity.httpMethodConstraints()) { final HttpMethodSecurityInfo httpMethodSecurityInfo = new HttpMethodSecurityInfo(); httpMethodSecurityInfo.setMethod(httpMethodConstraints.value()); httpMethodSecurityInfo.setEmptyRoleSemantic(get(httpMethodConstraints.emptyRoleSemantic())); httpMethodSecurityInfo.addRolesAllowed(httpMethodConstraints.rolesAllowed()); httpMethodSecurityInfo.setTransportGuaranteeType(get(httpMethodConstraints.transportGuarantee())); servletSecurityInfo.addHttpMethodSecurityInfo(httpMethodSecurityInfo); } servletInfo.setServletSecurityInfo(servletSecurityInfo); } final MultipartConfig multipartConfig = AnnotationsUtils.getFirstAnnotation(servletClass, MultipartConfig.class); if (multipartConfig != null) { final String location = StringUtils.isEmpty(multipartConfig.location()) ? SystemUtils.getJavaIoTmpDir().getAbsolutePath() : multipartConfig.location(); servletInfo.setMultipartConfig(new MultipartConfigElement(location, multipartConfig.maxFileSize(), multipartConfig.maxRequestSize(), multipartConfig.fileSizeThreshold())); } addServlet(servletInfo); return this; }