First, struts2-convention-plugin configuration file detailed
<constant name= "Struts.convention.actionConfigBuilder" value= "convention"/>
<constant name= "Struts.convention.actionNameBuilder" value= "convention"/>
<constant name= "Struts.convention.resultMapBuilder" value= "convention"/>
<constant name= "Struts.convention.interceptorMapBuilder" value= "convention"/>
<constant name= "Struts.convention.conventionsService" value= "convention"/>
<constant name= "Struts.convention.result.path" value= "/web-inf/content/"/>
Sets the root path for the Convention plug-in to locate the view resource. The default value is/web-inf/content/
<constant name= "Struts.convention.result.flatLayout" value= "true"/>
If set to False, the view page can be placed under the directory of the action (without placing the/web-inf/content/)
<constant name= "Struts.convention.action.suffix" value= "action"/>
Convention searches for the class name suffix of the action class. The default value is action
<constant name= "struts.convention.action.disableScanning" value= "false"/>
Whether to suppress the action by preventing the package from scanning. The default value is False
<constant name= "Struts.convention.action.mapAllMatches" value= "false"/>
Setting creates an action map even if there are no @action annotations. The default value is False
<constant name= "Struts.convention.action.checkImplementsAction" value= "true"/>
Sets whether the class that implements the action interface is mapped to action. The default value is Ture
<constant name= "Struts.convention.default.parent.package" value= "Convention-default"/>
Sets the default parent package for the package where the action for the Convention map is located. The default value is Convention-default
<constant name= "Struts.convention.action.name.lowercase" value= "true"/>
Sets the Name property value of the action to all lowercase letters when the mapping action is set. The default value is True
<constant name= "Struts.convention.action.name.separator" value= "-"/>
Specifies the delimiter between the words in the specified Name property when the mapping action is set. The default value is the draw line
<constant name= "struts.convention.package.locators" value= "Action,actions,struts,struts2"/>
The Convention plug-in uses this constant to specify that the package's default value for the root package as a search action is ACTION,ACTIONS,STRUTS,STRTUS2
<constant name= "Struts.convention.package.locators.disable" value= "false"/>
Specifies that the action is forbidden from the root package of the action. The default value is False
<constant name= "Struts.convention.package.locators.basePackage" value= ""/>
If the constant is specified, convention will only search for the action class from the package starting with the constant value.
<constant name= "Struts.convention.exclude.packages" value= "org.apache.struts.*,org.apache.struts2.*, Org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.* "/>
Specifies a package that is excluded from the search action. The default value is Org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2. *,org.hibernate.*
<constant name= "Struts.convention.relative.result.types" value= "Dispatcher,velocity,freemarker"/>
Specifies the result type that is supported by default when convention map results. The default value is Dispatcher,velocity,freemarker
<constant name= "Struts.convention.redirect.to.slash" value= "true"/>
Sets whether to redirect to a slash (/). For example, if a user requests/foo, but/foo does not exist, it can be redirected to/foo/if the constant is set. The default value is True
<constant name= "Struts.convention.action.alwaysMapExecute" value= "true"/>
<constant name= "Struts.mapper.alwaysSelectFullNamespace" value= "true"/>
<!--<constant name= "Struts.convention.action.includeJars"/>-->
<constant name= "Struts.convention.action.fileProtocols" value= "jar"/>
<constant name= "Struts.convention.classes.reload" value= "false"/>
<constant name= "Struts.convention.exclude.parentClassLoader" value= "true"/>
Second, the project example
(a) Struts2-convention-plugin dependency package, placed in the project Lib directory:
(ii) Web.xml configuration
(iii) Strut2.xml configuration
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Struts Public
"-//apache Software foundation//dtd Struts Configuration 2.3//en"
"Http://struts.apache.org/dtds/struts-2.3.dtd" >
<struts>
<constant name= "Struts.devmode" value= "true"/> <!--development mode-->
<constant name= "Struts.configuration.xml.reload" value= "true"/> <!--config file reload-->
<constant name= "struts.i18n.encoding" value= "UTF-8"/> <!--Web application code-->
<constant name= "Struts.convention.result.path" value= "/"/> <!--the path of the Search view resource-->
<constant name= "Struts.convention.action.name.separator" value= "_"/> <!--action class name separator-->
<constant name= "Struts.convention.classes.reload" value= "true"/> <!--Convention class reload-->
<constant name= "Struts.convention.action.suffix" value= "action"/> <!--action suffix name-->
<constant name= "struts.action.extension" value= "action,do,html,htm,php,aspx"/> <!--action extension-->
<constant name= "struts.convention.package.locators" value= "Action,actions"/> <!--search for the package path for the action resource-->
<!--enable Dynamic method invocation true:actionname! Method.action This form is easy to use, false:actionname! method is not good with-->
<constant name= "Struts.enable.DynamicMethodInvocation" value= "true"/>
<!--result type-->
<constant name= "Struts.convention.relative.result.types" value= "Dispatcher,freemarker"/>
<!--based on what package-->
<constant name= "Struts.convention.package.locators.basePackage" value= "Net.yeah.fancydeepin.action"/>
<!--first letter lowercase-->
<constant name= "Struts.convention.action.name.lowercase" value= "true"/>
<!--check to see if Action--> is implemented
<package name= "Default" extends= "Struts-default" >
<interceptors>
<interceptor-stack name= "Defaultstack" >
<interceptor-ref name= "Exception"/>
<interceptor-ref name= "ServletConfig"/>
<interceptor-ref name= "Actionmappingparams"/>
<interceptor-ref name= "Staticparams"/>
<interceptor-ref name= "params"/>
</interceptor-stack>
</interceptors>
</package>
</struts>
(d) Create a new Demoaction class in the SRC directory, configured as shown in the following illustration:
(v) in the Project Webroot directory, add index.jsp and error.jsp,index.jsp file contents add
<a href= "./demo!error.action" > Build Error </a>