2013年11月14日星期四

springmvc upload problem

I use a springmvc occurred while Upload Files
org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest this error.
online solution I tried to add

104857600


4096


request form is submitted using the action when uploading files to solve the problem , everything is normal , but I can not do the project requirements page jump , so use the ajax method to submit the form , so that the original error appeared the .

I debug a bit and found the configuration bean multipartResolver seemingly did not play any role in the function of uploading files to get the type of request or org.apache.catalina.connector.RequestFacade while using action form is submitted, function obtained in the type of request is org.springframework.web.multipart.MultipartHttpServletRequest .

Why ? Should be how to solve it ? Please god exhibitions. Thank you !

------ Solution ------------------------------------ --------
can hide an iframe, had to use a form before they can
------ Solution ------------------ --------------------------
first to add your spring.xml











Then you upload method must be added
@ ResponseBody @ RequestMapping ("/ upload.shtml")
public void upload (@ RequestParam MultipartFile file , HttpServletRequest request, HttpServletResponse response) {
}

You try
------ For reference only ------------------------------- --------
used jquery grid 's look http://bbs.csdn.net/topics/390320766
------ For reference only - -------------------------------------
ajax 's post can not do file upload

------ For reference only ---------------------------------- -----
Thank goldenfish1919, with a hidden iframe can indeed achieve my desired effect.
4 floor of the way , I tried, so I do not know why , after writing not directly call contorller handler inside it. .
------ For reference only -------------------------------------- -
ajax can do file upload post , please use jquery.form.js can use ajxaForm

没有评论:

发表评论