Use struts path wildcard

Source: Internet
Author: User

Keyword: struts path wildcard usage


1. Use of struts2 wildcard

 

<Struts>
<Package name = "sshweb" extends = "struts-default" namespace = "/common">
<Action name = "* _ *" class = "{1}" method = "{2}">
<Result>/pages/{1}. jsp </result>
<Result name = "input">/jsp/{1}. jsp </result>
<Result name = "C0101001" type = "redirectAction"> C0101001_execute </result>
<Result name = "C0101002" type = "redirectAction"> C0101002_execute </result>
<Result name = "C0101003" type = "redirectAction"> C0101003_execute </result>
<Result name = "C0101004" type = "redirectAction"> C0101004_execute </result>
<Result name = "C0101005" type = "redirectAction"> C0101005_execute </result>
</Action>
</Package>
</Struts>

Note: The Path/TestAction_getMessage request will be sent to the getMessage method of the TestAction class for processing.

Or

<Package name = "user" extends = "struts-default" namespace = "/">
<Action name = "user _ *" class = "com. test. action. UserAction" method = "{1}">
<Result>/user _ {1}. jsp </result>
</Action>
</Package>

Note: The Path user_zhaoshijie request will be handed over to the zhaoshijie method for processing.


2. Use the struts1 wildcard

<Struts-config>
<Action-mappings>
<Action path = "/test/TestAction _ *" type = "com. test. action. TestAction" parameter = "{1} TestAction">
<Forward name = "add" path = "/test/addTest. jsp"/>
</Action>
</Action-mappings>
 
</Struts-config>

Note: The Path/test/TestAction_zhaoshijie request will be handed over to the zhaoshijieTestAction method for processing.


Or


<Action
Path = "/Edit *"
Type = "com. oreilly. strutsckbk. ch07.Edit {1} Action"
Name = "{1} Form"
Scope = "request"
Validate = "false">
<Forward
Name = "success"
Path = "/edit _ {1}. jsp"/>
</Action>

<Action
Path = "/Save *"
Type = "com. oreilly. strutsckbk. ch07.Save {1} Action"
Name = "{1} Form"
Scope = "request"
Validate = "true"
Input = "edit _ {1}. jsp">
<Forward
Name = "success"
Path = "/saved _ {1}. jsp"/>
</Action>

Author: "Zhao Shijie's blog"

Related Article

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.