One,struts2-convention-plugin configuration file specific explanation
<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 of the Convention plug-in Location 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 corresponding folder of action (without putting/web-inf/content/)
<constant name= "Struts.convention.action.suffix" value= "action"/>
Convention searches the class name suffix of the action class. The default value is action
<constant name= "struts.convention.action.disableScanning" value= "false"/>
Whether to scan the action by preventing the package. The default value is False
<constant name= "Struts.convention.action.mapAllMatches" value= "false"/>
Set even without @action gaze. The action map is still created. 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 for which the Convention mapping action is located.
The default value is Convention-default
<constant name= "Struts.convention.action.name.lowercase" value= "true"/>
Sets whether the Name property value of the action is converted to all letters lowercase when the action is mapped. The default value is True
<constant name= "Struts.convention.action.name.separator" value= "-"/>
Sets the delimiter between a word that specifies the value of the Name property when mapping the action. The default value is the PIP line
<constant name= "struts.convention.package.locators" value= "Action,actions,struts,struts2"/>
The Convention plugin uses this constant to specify that the package as the root package for the search action is the default value of Action,actions,struts,strtus2
<constant name= "Struts.convention.package.locators.disable" value= "false"/>
Specifies that the action from the root package of the action is forbidden. The default value is False
<constant name= "Struts.convention.package.locators.basePackage" value= ""/>
Assuming that the constant is specified, convention only searches for the action class from the package that starts with that 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 the package 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 maps result. 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. Assume that the constant is set to be redirected to/foo/. 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, project instances
(a) Struts2-convention-plugin dependency package, placed under the Projectlib folder:
(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 Model--
<constant name= "Struts.configuration.xml.reload" value= "true"/><!--configuration file is loaded again-
<constant name= "struts.i18n.encoding" value= "UTF-8"/><!--Web usage code--
<constant name= "Struts.convention.result.path" value= "/"/><!--the path to the Search view resource--
<constant name= "Struts.convention.action.name.separator" value= "_"/> <!--Action class name delimiter--
<constant name= "Struts.convention.classes.reload" value= "true"/> <!--Convention class overload-in
<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 the package path of the action resource--
<!--enable Dynamic method invocation true:actionname! Method.action in this form. false:actionname! method is not good to use--
<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"/>
<!--name first letter---
<constant name= "Struts.convention.action.name.lowercase" value= "true"/>
<!--Check 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>
(iv) Under the SRC folder, create a new Demoaction class, configured for example, as seen:
(v) Under the Projectwebroot folder, add the contents of index.jsp and error.jsp,index.jsp files.
<a href= "./demo!error.action" > Generate Errors </a>
Java Pain Learning Path [IV]---about struts2-convention-plugin use