This function is better when there are many Struts configuration files that need to be divided or separated into multiple configuration files.
Use the <include> label to introduce other configuration files to the Struts. xml configuration file.
For example, a login. xml configuration file is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC
"-// Apache Software Foundation // DTD Struts Configuration 2.0 // EN"
Http://struts.apache.org/dtds/struts-2.0.dtd>
<Struts>
<Package name = "login" extends = "struts-default" namespace = "/login">
<Action name = "login *" class = "com. bjsxt. struts2.user. action. LoginAction {1}">
<Result>/user_login_success.jsp </result>
</Action>
</Package>
</Struts>
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC
"-// Apache Software Foundation // DTD Struts Configuration 2.0 // EN"
Http://struts.apache.org/dtds/struts-2.0.dtd>
<Struts>
<Package name = "login" extends = "struts-default" namespace = "/login">
<Action name = "login *" class = "com. bjsxt. struts2.user. action. LoginAction {1}">
<Result>/user_login_success.jsp </result>
</Action>
</Package>
</Struts>
[Html] view plaincopyprint?
You need to use the <include> label in the struts. xml file to introduce it. Struts. xml is as follows
[Java] <? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC
"-// Apache Software Foundation // DTD Struts Configuration 2.0 // EN"
Http://struts.apache.org/dtds/struts-2.0.dtd>
<Struts>
<Constant name = "struts. devMode" value = "true"/>
<Include file = "login. xml"/>
</Struts>
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC
"-// Apache Software Foundation // DTD Struts Configuration 2.0 // EN"
Http://struts.apache.org/dtds/struts-2.0.dtd>
<Struts>
<Constant name = "struts. devMode" value = "true"/>
<Include file = "login. xml"/>
</Struts>
1. Default Action
The default Action is used when the user accesses the namespace for the next Action that does not exist.
Use the <default-action-ref name = "name"> label. The name attribute points to the Action name defined below.
[Html] <struts>
<Constant name = "struts. devMode" value = "true"/>
<Package name = "default" namespace = "/" extends = "struts-default">
<Default-action-ref name = "index"> </default-action-ref>
<Action name = "index">
<Result>/default. jsp </result>
</Action>
</Package>
</Struts>
<Struts>
<Constant name = "struts. devMode" value = "true"/>
<Package name = "default" namespace = "/" extends = "struts-default">
<Default-action-ref name = "index"> </default-action-ref>
<Action name = "index">
<Result>/default. jsp </result>
</Action>
</Package>
</Struts>
When no Action exists under the current access namespace = "/", the system returns the automatically forwarded to the access/default. jsp page.
I. Action Summary
1. The most common way to implement an Action: Inherit from ActionSupport
2. DMI dynamic call :!
3. wildcard configuration: * {1} {2}
4. Method of receiving parameters (generally, properties or DomainModel are used to receive parameters)
5. Simple parameter verification addFieldError
A) generally, the Struts UI tag is not used.
6. Access Web elements
A) Map type
I. IoC
Ii. Dependency on Struts2
B) Original Type
I. IoC
Ii. Dependency on Struts2
7. Include File Configuration