1. Packages that need to be imported
Struts2-convention-plugin-2.3.14.jar
Asm-3.3.jar
Asm-commons-3.3.jar
Asm-tree-3.3.jar
2. Rules for path access
Struts2-convention-plugin-*jar package, this package will default to retrieve the package name contains Struts,struts2,action,actions package, It then handles these classes that implement the action interface and the class name ends with action as action. Do not <init-param><param-name>actionpackages in the filter in Web. Xml ... Configuration is also possible.
Mapping Rules:
For classes that end in action, remove the action, take the remainder, convert all letters to lowercase, and if you have a camel-like notation, use the "-" connector to connect different words, which is the default way for this plugin. After the final conversion is the request address, see an example below:
(1)com.han.action.OrderAction This class according to the above rules, the result path is/order.action, access to the URL is: http://localhost:8080/ Project Name/order.action
(2) If your package name is in the back of the struts,sturts2,action,action2 and there are other words, then the next part is the default namespace, such as:
Com.han.action.other.OrderAction, the request path is:/other/order.action
(3) We also often use the hump naming method, and its default parsing rule is to use "-" connectors to connect different words, such as:
Com.han.action.UserOrderAction This request path is:/user-order.action
(4) If you have more than one keyword in your package name, it will be parsed in the order I wrote above, such as:
Com.han.struts.action.OrderAction, which contains struts and action while the default struts has a higher priority then the action is treated as a normal character (the default is the namespace).
So the request address is:/action/order.action;
And if it is: com.han.action.struts.OrderAction (because struts has a high priority) The end result is:/order.action
3. Modify the keywords that are retrieved by default
So what if we don't want to follow its default keywords to retrieve it? There is a way to modify the keyword that it retrieves by Struts.xml's constant configuration:
<constant name= "struts.convention.package.locators" value= "Han"/>
So let it default to the package name contains Han to determine the action