|
16 | 16 | package org.noear.solon.server.tomcat; |
17 | 17 |
|
18 | 18 | import org.apache.catalina.Context; |
| 19 | +import org.apache.catalina.Wrapper; |
19 | 20 | import org.apache.catalina.connector.Connector; |
20 | 21 | import org.apache.catalina.startup.Tomcat; |
21 | 22 | import org.noear.solon.core.util.IoUtil; |
@@ -54,25 +55,24 @@ protected Context initContext() { |
54 | 55 | // for context |
55 | 56 | Context context = _server.addContext("/", null);//第二个参数与文档相关 |
56 | 57 |
|
57 | | - MultipartConfigElement multipartConfig = new MultipartConfigElement( |
58 | | - _tempdir, |
59 | | - ServerProps.request_maxFileSize, |
60 | | - ServerProps.request_maxFileRequestSize(), |
61 | | - ServerProps.request_fileSizeThreshold); |
62 | | - |
63 | | - context.getServletContext().setAttribute("org.apache.catalina.MultipartConfigElement", multipartConfig); |
64 | 58 | context.setAllowCasualMultipartParsing(true); |
65 | 59 |
|
66 | 60 | if (SessionProps.session_timeout > 0) { |
67 | 61 | context.setSessionTimeout(SessionProps.session_timeout); |
68 | 62 | } |
69 | 63 |
|
70 | 64 | // for http |
71 | | - Tomcat.addServlet(context, "solon", new TCHttpContextHandler()) |
72 | | - .setAsyncSupported(true); |
| 65 | + MultipartConfigElement multipartConfig = new MultipartConfigElement( |
| 66 | + _tempdir, |
| 67 | + ServerProps.request_maxFileSize, |
| 68 | + ServerProps.request_maxFileRequestSize(), |
| 69 | + ServerProps.request_fileSizeThreshold); |
73 | 70 |
|
74 | | - context.addServletMappingDecoded("/", "solon");//Servlet与对应uri映射 |
| 71 | + Wrapper servlet = Tomcat.addServlet(context, "solon", new TCHttpContextHandler()); |
| 72 | + servlet.setAsyncSupported(true); |
| 73 | + servlet.setMultipartConfigElement(multipartConfig); |
75 | 74 |
|
| 75 | + context.addServletMappingDecoded("/", "solon");//Servlet与对应uri映射 |
76 | 76 |
|
77 | 77 | return context; |
78 | 78 | } |
|
0 commit comments