Spring MVC file upload

I. step summary Import jar package Configure web.xml Create configuration file mvc.xml in src directory Create the front page fileupload.jsp Create co...

I. step summary

  1. Import jar package
  2. Configure web.xml
  3. Create configuration file mvc.xml in src directory
  4. Create the front page fileupload.jsp
  5. Create controller class HelloController
  6. Configure mvc.xml file
  7. Create the folder JSP in the web inf directory, and create the file success.jsp

II. Detailed steps

1. Import jar package
commons-logging-1.1.1.jar jackson-annotations-2.5.4.jar jackson-core-2.5.4.jar jackson-databind-2.5.4.jar spring-aop-4.1.6.RELEASE.jar spring-beans-4.1.6.RELEASE.jar spring-context-4.1.6.RELEASE.jar spring-core-4.1.6.RELEASE.jar spring-expression-4.1.6.RELEASE.jar spring-tx-4.1.6.RELEASE.jar spring-web-4.1.6.RELEASE.jar spring-webmvc-4.1.6.RELEASE.jar //On this basis, import two more jar packages commons-fileupload-1.2.2.jar commons-io-2.0.1.jar

2. Configure web.xml
<filter> <filter-name>encoding</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-name>encoding</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
web.xml key code

4 December 2019, 00:39 | Views: 5447

Add new comment

For adding a comment, please log in
or create account

0 comments