Spring MVC notes

xiaoxiao2021-03-06  41

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 org.springframework.web.servlet.dispatcherservlet ContextconfigLocation /Web-inf/config.xml dispatcher *. Do DispatcherServlet scheders according to config.xml, distributes the request to each logic processing unit, equivalent to the ActionServlet in Struts.

4. Configure config.xml

- definition of view resolver -> ORG. Springframework.web.servlet.view.jstlview / web-inf / view / .jsp LoginAction < Bean id = "loginaction" class = "com.maxway.Action.loginaction> Loginfail 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 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 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.

转载请注明原文地址:https://www.9cbs.com/read-52895.html

New Post(0)