First, plug-in download:
Method One: In the menu item select Help---->>install New software---->> on the Install page select Add----->> Enter in Location:/http dist.springsource.com/release/tools/update/e4.5/(where 4.5 represents the Eclipse version number)
To view the Eclipse version number method: Select Help------>>aboat Eclipse in the menu item or find readme_eclipse.html in the Eclipse directory
Author Directory for D:\eclipse\readme\readme_eclipse.html
Method Two: Select Help---->>eclipse Marketplace in the menu item to search for SPRINGMVC and then click Install directly to wait for the installation to restart Eclipse.
Second, import the relevant package:
–commons-logging-1.1.3.jar
–spring-aop-4.0.0.release.jar
–spring-beans-4.0.0.release.jar
–spring-context-4.0.0.release.jar
–spring-core-4.0.0.release.jar
–spring-expression-4.0.0.release.jar
–spring-web-4.0.0.release.jar
–spring-webmvc-4.0.0.release.jar
Related Package The author has already shared the Baidu cloud disk, the need for friends can download here:
Link Address: Http://pan.baidu.com/s/1pLkH9KR
Password: xz8z
Iii. Creation of the project
Configuration of the 3.1:web-xml:
Select alt+/Select Dispatherservlet and press ENTER to automatically generate the following
<!--the front controller of this Spring WEB application, responsible-handling all application requests-
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:DoubleKill.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!--Map all requests to the dispatcherservlet for handling and
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Then configure Param-value to set it to Classpath:xxx.xml
XXX represents the file name of the new spring Bean Configuration file
Then set: Url-pattern which/means to intercept all, also can set the corresponding file name to intercept
3.2 Creating a spring Bean Configuration File:
Tick Bean context MVC option when creating
After a successful creation, the following code is generated automatically:
<?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:context= "Http://www.springframework.org/schema/context"Xmlns:mvc= "Http://www.springframework.org/schema/mvc"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://Www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsdhttp//Www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"></beans>
Must be added on the </beans> tab
<context:component-scan base-package= "" ></context:component-scan> label
where base-package= "" is the value of the package to be scanned eg:base-package= "com.tyd.spring"
3.3 Create a Java project:
Author Code:
Just create a normal class and then add @Controller to the class class and import the relevant package
Establish a connection: Create a method for related operations add @RequestMapping () inparentheses to the connection name, following is a sample of the author's simple code:
Package com.tyd.spring; Import Org.springframework.stereotype.Controller; Import org.springframework.web.bind.annotation.RequestMapping; Import Org.springframework.web.bind.annotation.RequestMethod; @Controller Public class myspring { @RequestMapping (value= "/sayok") public String sayok () { return "/web-inf/view/success.jsp"; }}
JSP page:
<%@ 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" >
Initial solution of SPRINGMVC