Monday 15 August 2011

Spring + DWR fie upload size restriction -


I be uploaded into an application, which can use the files MultiPartRequest or DWR application Could.

I have the following configuration.

Web.xml

  & lt; Servlet & gt; & Lt; Servlet-name & gt; Nerp & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Org.springframework.web.servlet.DispatcherServlet & lt; / Servlet-class & gt; & Lt; Init-param & gt; & Lt; Ultimate Name & gt; FileUploadMaxBytes & lt; / Lastname & gt; & Lt; Ultimate Price & gt; 5000 & lt; / Super-valued & gt; & Lt; / Init-param & gt; & Lt; Load-On-Startup & gt; 1 & lt; / Load-on-startup & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Nerp & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Nerp / * & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Nerp & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / DWR / * & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt;   

nerp-servlet.xml

  & lt; Beans: bean id = "multipartResolver" class = "com.resources. Erp.util.ERPMultiPartResolver" & gt; & Lt ;! - One of the available properties; Maximum file size in bytes - & gt; & Lt; Beans: property name = "maximum load size" value = "100000" /> & Lt; / Bean: beans & gt;   

ERPMultiPartResolver

  public class ERPMultiPartResolver extends CommonsMultipartResolver {@Override public boolean isMultipart (Last HttpServletRequest request) {boolean isMultiPartBoolean = true ; Last string urlFromBrowserWithAppName = String.valueOf (request.getRequestURI ()); String urlFromBrowser = ""; if (! urlFromBrowserWithAppName = NULL) {urlFromBrowser = urlFromBrowserWithAppName.replaceAll (String.valueOf (request.getContextPath ()), ""); } If (urlFromBrowser.indexOf ("dwr")> {} is MultiPartBoolean = false; } Else {is MultiPartBoolean = super.isMultipart (requested); } Return is MultiPartBoolean; }   

}

I MultiPartRequest Related upload size maxUploadSize Property of ERPMultiPartResolver . But I'm not able to restrict the size of the DWR file upload.

I tried to use param.name fileUploadMaxBytes in web.xml but the size of the image is not being restricted

Can someone please dur me Uploading can help to limit the size of the image when both Spring 3.2.1 and DRT 3.0 are being used in the project?

I have checked the link

The answer to the above question is that Instead, the announcement to declare fileUploadMaxBytes in web.xml in the above way should be in place where you configure your dwrContoller. I.e.

  & lt; Dwr: controller id = "dwrController" debug = "true" & gt; & Lt; Dwr: config-param name = "fileUploadMaxBytes" value = "1048" /> & Lt; / DWR: Controller & gt;   

Now with the help of this, I am able to limit the image size to 1048 bytes.

Before my dwrController configuration is shown as below

      

No comments:

Post a Comment