1 public String upload2(MultipartHttpServletRequest request, @RequestParam("name") String name){ 2 List<MultipartFile> files = (List<MultipartFile>) request.getFile("myfiles"); 3 } 4 //修改成如下方法,还是报同样下面的错误: 5 public String upload2(MultipartHttpServletRequest request, @RequestParam("name") String name, // 页面上的控件值 6 @RequestParam MultipartFile[] myfiles) { 7 List<MultipartFile> files = Arrays.asList(myfiles); 8 } 9 // jsp页面,传一个myfiles,单个文件是可以通过的,
<form method="POST" action="multipartFileUpload.action"
enctype="multipart/form-data">
<input type="text" name="name" /><br>
<input type="file"name="myfiles" /><br>
<input type="file"name="myfiles" /><br>
<input type="submit" /><br>
</form>
org.springframework.web.multipart.MultipartException: Multiple files for field name [myfiles] found - not supported by MultipartResolver at org.springframework.web.multipart.commons.CommonsFileUploadSupport.parseFileItems(CommonsFileUploadSupport.java:254) at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:166) at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:149) at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1015) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:851) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511) at javax.servlet.http.HttpServlet.service(HttpServlet.java:643) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619)
在线等,期待解答...
试试 request.getParameter("name")
修改了spring版本,2.5.6 修改为3.2.2,可以使用
request.getFiles("myfiles");
public @ResponseBody Result insertInfo(@RequestParam MultipartFile file,
不要[]看看
大侠 ,结果怎么样了啊。
页面用HTML5 试试这个 <input type="file" name="myfiles" multiple="multiple"
/>