Eighth chapter. Building a WEB layer
Spring's MVC and Struts's MVC are basically consistent.
Spring's control process is: request->dispatcherservlet-> to query from handlermapping to the controller-> Controller that handles the request HandleRequest Method invokes the business method, and finally returns Modelandview (Modelandview tells Dispatcherservlet which view to turn to)
The control process for Struts is to request->actionservlet-> from the actionmapping to query the Execute method calling the business method from the Controller (Action Class)->action that handles the request. Finally returns Actionforward (Actionforward tells Actionservlet which view to turn to) (P243)
The dispatcherservlet of the Actionservlet Spring and Struts are configured in the same way as a self-booting Servlet configured into Web.xml. Spring's url-pattern Configuration convention is *.htm, and Struts is usually configured as *.do or *.action, exposing the technology used by the Web. (P244)
The. Spring is configured with
<servlet-mapping>
<servlet-name>unmi</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
, the/web-inf/unmi-servlet.xml file is automatically loaded when the corresponding Dispatcherservlet is initialized, which is a normal Spring Bean configuration file and is also loaded by Webapplicationcontext. Other Bean configuration files need to be loaded as usual by Contextloaderlistener or contextloaderservlet. The Bean to be used inside Spring MVC is obtained from the Unmi-servlet.xml (P244)
What, Struts 1.2? You can inject simple properties into the Action in Struts-cnfig.xml, and Spring configuration controller can inject all type attributes (P247)
74. In the following code configured in Unmi-servlet.xml, Spring will assign to homecontroller the request URL that is the end of "/home.html", Dispatcherservlet the default processor mapping used is B Eannameurlhandlermapping (P247)
<bean name= "/home.html" class= "Com.unmi.HomeController" >
<property name= "Greeting" ><value>welcome to Spring
training</value></property>
</bean>