The larger the application, the more action mappings there are. By using wildcards, We can bind some similar mappings together and use a more general mapping representation, the use of this wildcard is also mentioned in the previous chapter on action configuration. Here we will talk about it systematically.
There is a configured action ing as follows:
<Action
Name = "/edit *"
Class = "org. Apache. Struts. webapp. example. Edit {1} action">
<Result name = "failure" Path = "/mainmenu. jsp"/>
<Result Path = "/{1}. jsp"/>
</Action>
This action mapping can be used to match all action names starting with/edit, such as/editsubstration and editregistration, but/editsubscription/Add will not be matched. The content matched by the wildcard will be replaced with the action mapping and result attributes to replace {1 }. For example, if the/editsubpipeline matches, the path attribute of one of the results will be considered as subpipeline. jsp by the framework.
It should be noted that if the URL of a request matches multiple action mappings, select the last execution, that is, perform matching search in the order from the back to the back, one exception is that exact match takes precedence. If there is an action mapping that does not use wildcards or URLs for matching, the exact match takes precedence, equivalent to the matching principle in servlet.
The following describes some special characters in a wildcard:
*: It can match 0 or multiple arbitrary characters, but does not include the forward slash "/";
**: It can match zero or multiple arbitrary characters, including the forward slash ''/".
/: Backslash, escape character.
Because * does not match the forward slash, the Front/editsub/Add will not be matched.
In action mapping, the value matched by the wildcard can be accessed with the symbol {n}, where n is a number between 1 and 9, it is used to represent the value on which the nth value is matched. The popular point is the content indicated by the nth * number. For example, the wildcard expression is/edit */Add */confirm *, it matches/editorder/additem/confirmresult, so {1} indicates order, {2} indicates item, {3} indicates result, and so on.