1. importing the jar Package
Commons-logging-1.2.jar
Spring-aop-4.3.6.release.jar
Spring-beans-4.3.6.release.jar
Spring-context-4.3.6.release.jar
Spring-context-support-4.3.6.release.jar
Spring-core-4.3.6.release.jar
Spring-expression-4.3.6.release.jar
Spring-web-4.3.6.release.jar
Spring-webmvc-4.3.6.release.jar
Taglibs-standard-compat-1.2.5.jar
Taglibs-standard-impl-1.2.5.jar
Taglibs-standard-jstlel-1.2.5.jar
Taglibs-standard-spec-1.2.5.jar
2.web.xml Configuration
<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version= "3.0"> <Display-name>01springmvc_mvc</Display-name> <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> <welcome-file-list> <Welcome-file>index.jsp</Welcome-file> </welcome-file-list></Web-app>
Attention:
< init-param > < param-name > contextconfiglocation</ param-name > < param-value > classpath: Mvc.xml</ param-value > </ init-param >
Indicates the configuration file location (src/mvc.xml) Focus of MVC
3.Controller
Public class Hellocontroller { @RequestMapping ("/hello") public Modelandview Hello ( HttpServletRequest req, HttpServletResponse resp) { new Modelandview (); // encapsulate the data to be displayed in the view Mav.addobject ("msg", "Hello Springmvc"); // View name Mav.setviewname ("Hello"); return Mav;} }
4.SPRINGMVC Configuration
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "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-conte Xt.xsd "> <!--Configuring the Renderer - <BeanID= "Jspviewresolver"class= "Org.springframework.web.servlet.view.InternalResourceViewResolver"> < Propertyname= "Viewclass"value= "Org.springframework.web.servlet.view.JstlView"/> <!--the prefix of the result view - < Propertyname= "prefix"value= "/web-inf/jsp/"/> <!--suffix of the result view - < Propertyname= "suffix"value= ". jsp"/> </Bean> <!--Scan for annotations under this package - <Context:component-scanBase-package= "Com.springmvcanno"/></Beans>
Developing SPRINGMVC with annotations