Try to write a login that uses the Spring MVC according to the xiaxin document.
Contains in the document
Http://www.xiaxin.net/spring_dev_guide.rar.
1. surroundings
Tomcat5.0 or more. Because the sample program uses JSP Standard Tag Library (JSTL), I have been using Tomcat4, depressed.
2. Jar package
Spring.jar
Commons-logging.jar
JSTL.JAR gets from Spring-frameWork directory / lib / j2ee
Standard.jar is obtained from Spring-frameWork catalog / lib / jakarta-taglibs (it seems to be no need, no Tomcat5, no test)
3. Configure web.xml
Dispatcher servlet-name> org.springframework.web.servlet.dispatcherservlet servlet-class> ContextconfigLocation param Name> /Web-inf/config.xml param-value> init-param> servlet> dispatcher servlet-name> *. Do url-pattern> servlet-mapping> DispatcherServlet scheders according to config.xml, distributes the request to each logic processing unit, equivalent to the ActionServlet in Struts.
4. Configure config.xml
XML Version = "1.0" encoding = "UTF-8"?>
- definition of view resolver -> ORG. Springframework.web.servlet.view.jstlview value> proty> / web-inf / view / value> proty> .jsp value> proty> bean> LoginAction prop> props> property> bean> < Bean id = "loginaction" class = "com.maxway.Action.loginaction> Loginfail value> proty> Nodes can have multiple mapping relationships, and we only define one. ⑹ LoginAction definitions here define the specific implementation of logical processing unit LoginAction, here, LoginAction's implementation class is com.maxway.Action.loginAction. ⑺ LoginAction Request Data Objects The CommandClass parameter originates from the base class baseCommandController, BaseCommandControlle, contains BaseCommandController.bindandValidate, which will request data objects based on the incoming HTTPServletRequest construct. ⑻ Return to the view definition For LoginAction here, there are two returned results, that is, the error interface is returned when the login fails, and the system main interface is entered when logging in. Corresponding to we have configured five custom parameters for Fail_View, Success_View. The parameter value will be processed by the resolver, add the prefix suffix, such as for Fail_View, the actual view path is /Web-inf/View/loginfail.jsp. After that, Resolver will blend the return data of the LoginAction with the view to return the final display interface. PS: 1. Original Org.SpringFramework.web.servlet.view.jstlview value> I have written 3 lines, but I seem to have a space before and after running in Tomcat4, causing this class, It is okay to be initialized normally, it is fine if it is changed. 2. com.maxway.action.loginInfo value> property> This is equivalent to FORMBEAN in Struts, but does not need to inherit anything, very simple Get / set is ,very nice. 5. The write logic processing unit This example is the verification unit. 1.