1
我有一個應用程序,可以使用MultiPartRequest
或DWR將文件上載到應用程序中。Spring + DWR fie上傳大小限制
我有以下配置。
Web.xml中
<servlet>
<servlet-name>nerp</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>fileUploadMaxBytes</param-name>
<param-value>5000</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>nerp</servlet-name>
<url-pattern>/nerp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>nerp</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
NERP-servlet.xml中
<beans:bean id="multipartResolver"
class="com.resources.erp.util.ERPMultiPartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<beans:property name="maxUploadSize" value="100000"/>
</beans:bean>
ERPMultiPartResolver
public class ERPMultiPartResolver extends CommonsMultipartResolver {
@Override
public boolean isMultipart(final HttpServletRequest request) {
boolean isMultiPartBoolean = true;
final String urlFromBrowserWithAppName = String.valueOf(request.getRequestURI());
String urlFromBrowser = "";
if(urlFromBrowserWithAppName != null) {
urlFromBrowser = urlFromBrowserWithAppName.replaceAll(String.valueOf(request.getContextPath()),"");
}
if(urlFromBrowser.indexOf("dwr") > 0) {
isMultiPartBoolean = false;
}
else {
isMultiPartBoolean = super.isMultipart(request);
}
return isMultiPartBoolean;
}
}
我的MultiPartRequest
相關上傳被限制在ERPMultiPartResolver
的maxUploadSize
屬性中指定的大小。但我無法限制DWR文件上傳的大小。
我嘗試在web.xml中使用參數名稱fileUploadMaxBytes
,但圖像大小沒有受到限制。
有人可以請幫我瞭解如何在項目中使用Spring 3.2.1和Dwr 3.0時通過DWR上傳限制圖像大小?
我檢查了鏈接