Unmi's Struts2 Learning notes (III.)

Source: Internet
Author: User
Tags constant i18n

A few days of continuous stay up, so that left chest and pain, how come so hard? Not from the thought, life so far, the impression has never been comfortable and happy feeling. Often avoid stinging pain.

1. WebWork's core controller is Servletdispatcher, mapped to *.action <url-pattern>. In WebWork and Struts2 struts.xml and struts.properties correspond to the Xwork.xml and webwork.properties respectively, the contents of the file are almost the same, only a few key words differ.

2. <action in the struts.xml of Struts2. The/> Name property is equivalent to the <action of Struts1. The path attribute of the/>, but you do not need to start with "/" here.

3. When a business logic component instance is used in the Action, it is usually not directly New, but through the factory method or IOC container. Although WebWork has an IOC container, STRUTS2 usually uses Spring's IOC.

4. Struts.xml can be split into multiple documents, such as Struts-part1.xml, Struts-part2.xml ... And so on, and then in the Struts.xml <include file= "Struts-part1.xml"/>, <include file= "Struts-part1.xml"/> ... Can. Look at the Struts-default.xml in the Struts2-core-x.x.x.jar for how many things you have built.

5. Struts2 's official stated that it wanted to run in a container that supported servlet2.4/jsp2.0, but I still put that simple example (Web.xml web-app_2_3.dtd) into Tomcat 4.1.30 (support to Servlet2.) 3/jsp1.2) Under the operation, can work properly, I do not know what problems may arise.

6. Struts2 also provides a pluggable way to install plug-ins like Eclipse, and see a lot of Struts2-xxx-plugin.jar in the downloaded Struts2 lib directory, all of which have a struts-plugin.xml ( A struts.xml configuration file), the Struts-plugin.xml is automatically loaded when the Struts2-xxx-plugin.jar is copied into the Web-inf/lib. You can also do your own plug-in package like this. Property Struts.configuration.files=struts-default.xml,struts-plugin.xml,struts.xml in Struts.properties.

7. In Struts.properties, I think the more important attributes Struts.action.extension, Struts.serve.static.browserCache, Struts.enable.SlashesInActionNames, Struts.devmode, Struts.i18n.reload, Struts.configuration.xml.reload, Struts.custom.i18n.resources, struts.i18n.encoding. Many property values support multiple values separated by commas. The default property configuration is Default.properties.

8. By default, *.action request to STRUTS2 processing, you can also be changed to other extensions, as long as the struts.properties in the Struts.action.extension attribute values, such as Struts.action.extension=unmi,action, then *.unmi and *.action will be Struts2 processing.

9. Struts2 compared to Struts1 in the development of not only changed the Struts.xml without restarting the application, even changed the internationalization of resource files can not need to restart the application. Set struts.i18n.reload = True.

STRUTS2 provides two ways to manage Struts2 properties, either written in Struts.properties, or written in struts.xml configured as constant elements, such as <constant name= "struts.i 18n.reload "value=" true "/>. Believe that most people still tend to write in struts.properties.

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.