Struts development skills
After the development of China Telecom's major customer service project and the ongoing development of the China Telecom headquarters business analysis project, I have accumulated some techniques and skills for Struts1.1 and Tiles development, which are shown in a close-up to facilitate future development. At the same time, I believe it can help readers develop Struts.
Module configuration
1. Struts configuration file Definition
For a module in the system, you need to define the configuration of this module before development. The struts configuration file is named:
Struts-config-xxx.xml
Xxx is the lowercase English name or abbreviation of the module, such as: struts-config-sysman.xml
Note: "-" in the middle, rather than the "_" Connector
Save the configuration file in the "WEB-INFxml" folder and add the corresponding configuration file to the web. xml file.
Address, for example:
...
<Init-param>
<Param-name> config </param-name>
<Param-value>/WEB-INF/struts-config.xml,/WEB-INF/xml/struts-config-pages.xml,/WEB-INF/xml/struts-config-sysman.xml </param-value>
</Init-param>
...
Note: you must use the "," connector to separate configuration file names.
In addition, all static JSPs need to define their ". do" access in the configuration file and save
The content in the struts-config-pages.xml file is as follows:
...
<! -- Turn to homepage -->
<Action path = "/main" type = "org. apache. struts. actions. ForwardAction" parameter = "/main. jsp"/>
...
2. Tiles configuration file Definition
The framework configuration file of the system is a tiles-defs_zh_CN.xml (supporting international applications through the. properties file, the default is a tiles-defs.xml), the Framework Structure of the module needs to be defined in it, for example:
...
<! -- Define the default homepage -->
<Definition name = "default. frame" path = "/layouts/defaultLayout. jsp">
<Put name = "title" value = "Welcome to China Telecom Business Analysis System"/>
<Put name = "header" value = "/top. jsp"/>
<Put name = "body" value = "default. body"/>
<Put name = "footer" value = "/buttom. jsp"/>
</Definition>
<! -- Define the body of the default homepage -->
<Definition name = "default. body" path = "/layouts/main. jsp">
<Put name = "logon" value = "/logon. jsp"/>
<Put name = "date" value = "/layouts/date. jsp"/>
<Put name = "linkSite" value = "/layouts/link.html"/>
</Definition>