The Struts2 request matches multiple wildcard instances.

Source: Internet
Author: User

This article will introduce Struts2 requests to match multiple wildcard instances. I hope this tutorial will be helpful to you.

When our request matches multiple actions of strtus

1. For example, the request is:

LoginAction

2. The following is our struts configuration file:

The Code is as follows: Copy code
 
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE struts PUBLIC "-// Apache Software Foundation // DTD Struts Configuration 2.1 // EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<Struts>
<Constant name = "struts. custom. i18n. resource" value = "mess"/>
<Constant name = "struts. i18n. encoding" value = "GBK"/>
<Package name = "default" extends = "struts-default">
<Action name = "loginAction" class = "org. Rudiment. action. LoginAction1">
<Result name = "input">/login. jsp </result>
<Result name = "error">/error. jsp </result>
<Result name = "success">/welcom. jsp </result>
</Action>

<Action name = "* inAction" class = "org. Rudiment. action. LoginAction2">
<Result name = "input">/login. jsp </result>
<Result name = "error">/error. jsp </result>
<Result name = "success">/welcom. jsp </result>
</Action>

<Action name = "*" class = "org. Rudiment. action. LoginAction3">
<Result name = "input">/login. jsp </result>
<Result name = "error">/error. jsp </result>
<Result name = "success">/welcom. jsp </result>
</Action>
</Package>
</Struts>


3. matching analysis:

When the same action as the request is configured, struts will directly match this action. For example, in this example, strtus will match action name = "loginAction". If no identical action is configured, strtus uses this Action to process the query match from top to bottom, for example, if action name = "loginAction" is not configured, strtus will match action name = "* inAction" for action name = "* inAction" and action name = "*" because it is not the request is exactly the same, who configured struts to handle the business, so this is handled by action name = "* inAction. If we configure action name = "*" before action name = "* inAction", strtus submits the business processing to the action name =, instead of processing the action corresponding to "* inAction.

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.