Spring Learning, Spring in action notes (v)

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.