SpringMVC上傳檔案例子
Apache Tomcat/8.0.33
開發環境:Eclipse Java EE IDE for Web Developers.
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600
java version "1.8.0_65"
SpringMVC:4.2.6
新建一個Dynamic Web Project
新建web.xml
新建springmvc-servlet.xml<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 配置Servlet name 和class--> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- 配置servlet mapping --> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <!-- 配置filter name和class --> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <!-- 配置filter mapping --> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> </web-app>
新建cn.han.controller包<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- jsp 渲染器 --> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <!-- 對上傳的支援 需要commons-fileupload.jar和commons-io.jar的支援 設定(multipart渲染器) multipart就是file upload --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- one of the properties available; the maximum file size in bytes --> <!-- 10mb --> <property name="maxUploadSize" value="1000000"/> </bean> <!-- 註解掃描 --> <context:component-scan base-package="cn.han.controller"/> <!-- ... --> </beans>
新建HelloWorldController.java
新建form.jsppackage cn.han.controller; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.text.Normalizer.Form; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.servlet.ModelAndView; @Controller public class HelloWorldController { //|表單頁面 @RequestMapping("/form") public ModelAndView form() { ModelAndView mView=new ModelAndView(); mView.setViewName("form"); return mView; } //|上傳處理頁面 @RequestMapping(path="/upload",method = RequestMethod.POST) public ModelAndView upload(@RequestParam("file")CommonsMultipartFile upfile,HttpServletRequest req) throws IOException{ //|獲取在Web伺服器上的 絕對路徑 String path =req.getRealPath("/fileupload"); System.out.println(path); //|獲取輸入流 InputStream is=upfile.getInputStream(); //|檔案輸出流 OutputStream os =new FileOutputStream(new File(path,upfile.getOriginalFilename())); //|迴圈寫入 int length=0; byte [] buffer=new byte[128]; while((length=is.read(buffer))!=-1) { os.write(buffer,0, length); } is.close(); os.close(); //===渲染=== ModelAndView mView=new ModelAndView(); mView.setViewName("upload"); //|返回至渲染器 return mView; } }
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>上傳檔案</title>
</head>
<body>
<form action="upload.html" method="POST" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="上傳" />
</form>
</body>
</html>
upload.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>上傳結果</title>
</head>
<body>
恭喜~上傳成功~
</body>
</html>
還需要匯入jar包,包括Springmvc的所有包
commons-io.jar,commons-fileupload.jar
commons-logging-1.2.jar
jastl-1.1.2.jar,standard-1.1.2.jar
下面是我遇到的報錯以及解決辦法
HTTP Status 500 - Failed to convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]: no matching editors or conversion strategy found
type Exception report
message Failed to convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]: no matching editors or conversion strategy found
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]: no matching editors or conversion strategy found
org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:74)
org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:47)
org.springframework.validation.DataBinder.convertIfNecessary(DataBinder.java:688)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:520)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:353)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:173)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:444)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:432)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.web.multipart.commons.CommonsMultipartFile]: no matching editors or conversion strategy found
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:302)
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:108)
org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:64)
org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:47)
org.springframework.validation.DataBinder.convertIfNecessary(DataBinder.java:688)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:520)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:353)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:173)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:444)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:432)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.33 logs.
上面報錯說的是 無法從String轉化成CommonsMultipartFile ,其實就是 我的form表單有問題,把檔名發過去了 而沒有真正傳送二進位制檔案,需要設定
enctype="multipart/form-data"
下面是第二個報錯:
HTTP Status 500 - Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 100000 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (164406) exceeds the configured maximum (100000)
type Exception report
message Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 100000 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (164406) exceeds the configured maximum (100000)
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 100000 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (164406) exceeds the configured maximum (100000)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:979)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 100000 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (164406) exceeds the configured maximum (100000)
org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:162)
org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142)
org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1091)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:930)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (164406) exceeds the configured maximum (100000)
org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:965)
org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310)
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334)
org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115)
org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:158)
org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142)
org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1091)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:930)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.33 logs.
這裡一看就知道是配置CommonsMultipart渲染器的上傳檔案大小限制的原因
<property name="maxUploadSize" value="1000000"/>
下面還有一組報錯
HTTP Status 500 - D:\eclipse-jee-workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\01upload_test\fileupload\psbe.jpg (系統找不到指定的路徑。)
type Exception report
message D:\eclipse-jee-workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\01upload_test\fileupload\psbe.jpg (系統找不到指定的路徑。)
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.io.FileNotFoundException: D:\eclipse-jee-workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\01upload_test\fileupload\psbe.jpg (系統找不到指定的路徑。)
java.io.FileOutputStream.open0(Native Method)
java.io.FileOutputStream.open(FileOutputStream.java:270)
java.io.FileOutputStream.<init>(FileOutputStream.java:213)
java.io.FileOutputStream.<init>(FileOutputStream.java:162)
cn.han.controller.HelloWorldController.upload(HelloWorldController.java:38)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:497)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:178)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:444)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:432)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.33 logs.
Apache Tomcat/8.0.33
這個意思就是資料夾不存在 ,確實不存在,需要在D:\eclipse-jee-workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\01upload_test目錄下建立fileupload資料夾,因為eclipse預設部署的地方就是在D:\eclipse-jee-workplace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\下面,然而我們指定了目錄
,卻沒有那個目錄就報錯了。
專案執行截圖
相關推薦
SpringMVC上傳檔案例子
伺服器: Apache Tomcat/8.0.33 開發環境:Eclipse Java EE IDE for Web Developers. Version: Mars.2 Release (4.5.2) Build id: 20160218-0600 java versi
springMVC上傳檔案,MultipartHttpServletRequest、MultipartFile進行檔案上傳
這裡使用apache的開源jar包完成上傳功能,使用jar包分別是:common-fileupload.jar和common-io.jar 先編寫上傳檔案幫助類,如果需要區分檔案型別,可以將檔案字尾擷取進行判斷; springmvc-mvc.xml配置,這裡主要配置spri
springmvc 上傳檔案的時候.The request sent by the client was syntactically incorrect
出現這個問題的原因,下面這篇文章已經講得很清楚的。 http://blog.csdn.net/kunkun378263/article/details/41863101 我遇到的場景是:MultipartFile上傳檔案,提交表單的時候除了上傳檔案還有幾個數字。我們知
springboot/springmvc上傳檔案(CommonsMultipartResolver)
上一篇博文講到了(Servlet3.0支援)的檔案上傳:https://blog.csdn.net/frozenpower/article/details/81141297 這篇我們來看可配置的檔案上傳解析器CommonsMultipartResolver CommonsMultipartR
SpringMVC上傳檔案(圖片)並儲存到本地
SpringMVC上傳檔案(圖片)並儲存到本地 小記一波~ 基本的MVC配置就不展示了,這裡給出核心程式碼 在spring-mvc的配置檔案中寫入如下配置 <bean id="multipartResolver" class="org.springframewor
Springmvc上傳檔案
SpringMVC上傳檔案 <!-- 頁面檔案上傳三要素 --> <form action="/uploadFile.do" method="post" enctype="multipart/form-data"> <input
利用SpringMVC上傳檔案的Demo
前言: 檔案的上傳功能也在網站中發揮著不可替代的作用,這裡我就來講講簡單利用SpringMVC實現檔案的上傳。 這裡我的配置是這樣的: idea+maven+tomcat9+jdk8 我也將該專案的D
SpringMVC上傳檔案出現400 Bad Request錯誤
1.起因 寫了上傳檔案程式碼,用postman測試一下報400 Dad Request。 2.原因 看了下資料瞭解到使用SpringMVC上傳檔案需要在form表單中新增enctype="mult
記錄一個解決了一個晚上加一個白天的問題,關於springMVC上傳檔案的功能
在做檔案上傳功能,用到了springMVC的這個類 import org.springframework.web.multipart.MultipartFile; 但是不管前臺怎麼傳檔案的值都過不去,查了下需要在wen.xml 建立bean <bean
SpringMVC上傳檔案的三種方法
直接上程式碼吧,大夥一看便知 這時:commonsmultipartresolver 的原始碼,可以研究一下 http://www.verysource.com/code/2337329_1/commonsmultipartresolver.java.html 前臺:
SpringMVC上傳檔案的三種方式
直接上程式碼吧,大夥一看便知 前臺: <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html
springmvc上傳檔案出現400錯誤
1.程式碼如下:在上傳的時候出現400錯誤。 public AjaxJson saveSchoolProfile( SchoolProfileBean schoolProfileBean, @RequestParam(required = false) MultipartFile logo, @
檔案上傳時報如下錯誤springmvc上傳檔案報錯org.springframework.beans.BeanInstantiationException
在用springmvc+mybatis進行專案開發時,上傳檔案拋異常.. org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web
Error creating bean with name 'multipartResolver' SpringMVC 上傳檔案異常
HTTP Status 500 - Servlet.init() for servlet springmvc threw exception type Exception report message Servlet.init() for servlet springmvc threw exce
SpringMvc上傳檔案(阿里雲)
● springMvc 上傳檔案 springMvc.xml配置 <!-- SpringMVC上傳檔案時,需配置MultipartResolver處理器 --> <bean id="multipartResolver" class="o
SpringMVC上傳檔案進度顯示
效果圖: FileUploadController.java import java.io.File;
ssm框架下的SpringMVC上傳檔案的三種方式
commonsmultipartresolver 的原始碼,可以研究一下 點我 前端程式碼: <%@ page language="java" contentType="text/html; charset=utf-8" pageEncodin
springMVC上傳檔案大小限制以及超過限制後的自定義處理
在xml中加下如下配置 <!-- SpringMVC上傳檔案時,需要配置MultipartResolver處理器 --> <beanid="multipartResolve
使用springMVC上傳檔案時讀取不到檔案
注意事項:上傳檔案大小若小於2048,則不會生成臨時檔案 <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartRe
非常牛叉的樓主,自己的問題其實就是答案--用springmvc上傳檔案時報The current request is not a multipart request異常
http://bbs.csdn.net/topics/380167574?page=1 非常牛叉的樓主,自己的問題其實就是答案 原因在於目錄下有一個upload檔案導致的 小弟我用spring3.1.0做了一個上傳檔案的例子,但發現一個奇怪的問題