Struts Convention Plugin process (2.1.6 +), convention2.1.6
First add lib:
<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-config-browser-plugin</artifactId> <version>2.3.20</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-convention-plugin</artifactId> <version>2.3.20</version> </dependency>
Access http: // localhost: 8080/conv/config-browser/a. action to view all the currently mapped paths
The plugin is executed in the following order:
1. Find the following packages:struts
,struts2
,action
,actions
All the above packages found in depth are automatically used as the root directory
2. Then find the following classes in the package:com.opensymphony.xwork2.Action
Or it inherits com. opensymphony. xwork2.ActionSupport, or the class name ends with Action.
3. ing to url:
Com. example.Actions. MainAction->/maincom. example.Actions. Products. Display->/products/displaycom. example.Struts. Company. details. ShowCompanyDetailsAction->/company/details/show-company-details (all in lower case)
For example, you can skip some packages:struts.convention.exclude.packages
= Org. apache. struts. *, org. apache. struts2. *, org. springframework. web. struts. *, org. springframework. web. struts2. *, org. hibernate. * (skipped packages cannot be added, even if manually added)
Package name automatically searched:struts.convention.package.locators
= Action, actions, struts, struts2
The name of the automatically searched package starts with struts. convention. package. locators. basePackage =
End of the automatically searched Class Name: struts. convention. action. suffix = Action
Manually specify a specific package: struts. convention. action. packages =
4. By default, all results are found here:WEB-INF/content
For example, public class MyJsp extends ActionSupport {public String execute () {return"Here";}}
Public class HimJsp extends ActionSupport {@ Action ("My-jsp-here") // Implement chain by specifying it as a specific path, provided that there is no public String execute () {return"Yes";}}
It will eventually become,
You can set Automatic Reload:
<
constant
name="struts.devMode" value="true"/>
<
constant
name="struts.convention.classes.reload" value="true" />
Struts. convention. action. alwaysMapExecute = false disable automatic invocation of execute ()
Struts. convention. action. disableScanning = true disable Scanning
Struts. convention. action. mapAllMatches = true no @ Action is automatically mapped
Struts. convention. action. name. lowercase = false do not change to lower case
Struts. convention. action. name. separator = _ name separator
Struts. convention. action. eagerLoading = true can improve performance when Spring is not used.