Original link: http://sarin.iteye.com/blog/829738
The Spring MVC module is a concise Web application framework that implements the MVC pattern to handle HTTP requests and responses. Compared to the Struts series, SPRINGMVC's MVC is more pronounced, separating the controller and view definitions completely, and they don't need to be under a single namespace. It has all the benefits of spring, and the beans are more comfortable to configure. The annotation configuration of Spring 3 makes code writing more elegant. This example combines the spring MVC with the security framework for a small integration, only work can explain, not detailed exploration of its principles.
The first is to build the project, do a simple message publishing function, the code structure below, the use of Maven can be very good management dependencies:
The hierarchy is used, but the database operation is not used, just a short description, which is used by the security framework to authenticate the user later. Here's a look at the dependencies, so you can get a clearer picture of the spring hierarchy:
First look at the most basic Web Deployment profile Web.xml, write the configuration that is used, Spring 3 uses Dispatcherservlet to distribute the request, and the security framework threaded the filter mechanism for safe handling. The configuration is simple, like the following, the Web request uses the. htm form: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ? XML version = "1.0" encoding = "UTF-8"?> < Web-app Version = "2.5" xmlns = "Http://java.sun.com/xml/ns/javaee" &nbs p; 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" > < Context-param > < Param-value > /web-inf/board-service.xml /web-inf/board-security.xml </ Param-value > </context-param > < listener > < listener-class > org.springframework.web.context.contextloaderlistener</listener-class > </ Listener > < filter >