Article From:https://www.cnblogs.com/liuna369-4369/p/9970403.html

1.Create a new web dynamic project in Tomcat

2.Import jar package

3.springMVCThe browser sends a request to process the request to a page. It needs to build a processor to process the browser request, so the third step to create a handler class needs to inherit the controller interface.

The handler defines what type of object to create

Then call the addObject method to set attributeValue for AttributeName, and then call the setViewName method to set the page to jump.

4.Write the page to jump and get attributeValue through ${AttributeName}

5.In the third step, only a processing class is created, and there is no object of that class. So we need to write a spring container under the class path to generate the proxy object of the processing class. The ID starts with / and ends with. * (e.g. / some. do).

6Get the ID of the proxy object by registering the central dispatcher Dispatcher Servlet in web.xml, as follows

<!– Register the central dispatcher – & gt;
<servlet>
<servlet-name>springContainer name & lt; / servlet-name & gt;
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!– Specify the location and name of the Spring MVC configuration file – & gt;
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<!– Create the current servlet instance when starting the application – & gt;
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<!–
<url-pattern>The value of /*, not recommended as /, is best written as an extension, such as:.Do,.go.
–>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

 

Link of this Article: Spring MVC Writing Steps

Leave a Reply

Your email address will not be published. Required fields are marked *