struts2 constant configuration

 

The order of searching and loading constants in sturt2 is:
struts-default.xml (in struts2-core.jar file) 
struts-plugin.xml (in Struts2 plugin JAR files such as struts2-xxx.jar) 
struts.xml (default for web applications Struts2 configuration file) 
sturts.propreties (default Struts2 configuration file for Web application) 
web.xml (configuration file under Web application)
Note: If the same Struts2 constants are configured in different configuration files, the latter one The constant value of the configuration file overrides the constant value of the previous configuration.

 

	<!-- Set the default local property -->
	<constant name="struts.locale" value="zh_CN"/>

	<!-- Specify the default encoding set of the Web application, which is equivalent to calling the setCharacterEncoding method of HttpServletRequest-->
	<constant name="struts.i18n.encoding" value="UTF-8" />

	<!-- Specifies the request suffix that needs to be processed by Struts2. The default value of this attribute is action, that is, all requests matching *.action are processed by Struts2.
		  If the user needs to specify multiple request suffixes, separate them with commas.
	          The extension can be specified as empty, but there will be a problem, that is, some other servlets will map the address to /services/*, and now this address also becomes the address of the struts2 control range,
	          If the default configuration is used, it will report an error that the action cannot be found -->
	 <constant name="struts.action.extension" value="action,do" />

	<!-- Set whether the browser caches static content, the default value is true (used in production environment), it is best to close the development stage -->
	<constant name="struts.serve.static.browserCache" value="false" />

	<!-- When the content of the struts.xml file changes, whether the system automatically reloads the file, the default value is false (used in the production environment), it is best to open it in the development stage -->
	<constant name="struts.configuration.xml.reload" value="true" />

	<!-- Use in development mode, which can print out more detailed error messages-->
	<constant name="struts.devMode" value="true" />

	<!-- Set the view theme, the default is xhtml (simple, xhtml, css_xhtml, ajax) -->
	<constant name="struts.ui.theme" value="simple" />

	<!-- This attribute specifies that the action in Struts2 is created by the Spring container -->
	<constant name="struts.objectFactory" value="spring" />

	<!-- Specify the assembly mode of the spring framework, the assembly methods are: name, type, auto and constructor (name is the default assembly mode) -->
	<constant name="struts.objectFactory.spring.autoWire" value="type" />

	<!-- Specify the temporary storage directory when uploading files, use javax.servlet.context.tempdir by default -->
	<constant name="struts.multipart.saveDir" value="/tmp_file" />

	<!-- This attribute specifies the maximum number of bytes allowed for the entire request content in a Struts2 file upload-->
	<constant name="struts.multipart.maxSize" value="2097152" />

	<!-- Set whether to support dynamic method invocation, true is supported, false is not supported. To achieve zero configuration, dynamic method calls are required -->
	<constant name="struts.enable.DynamicMethodInvocation" value="true" />

	<!-- Set whether slashes can be used in action, the default is false, not, if you want to use it, you need to set it to true -->
	<constant name="struts.enable.SlashesInActionNames" value="true" />

	<!-- Whether to allow expression syntax, defaults to true. -->
 	<constant name="struts.tag.altSyntax" value="true" />

 	<!-- Set whether to reload the resource file for each request, the default value is false, it can be set to true for debugging -->
 	<constant name="struts.i18n.reload" value="true" />

	<!-- Set the internationalized resource files to be loaded, separated by commas -->
	<constant name="struts.custom.i18n.resources" value="application" />

	<!-- Set the list of files that struts automatically loads, separated by commas -->
	<constant name="struts.configuration.files" value="struts-default.xml,struts-plugin.xml,struts.xml" />

	<!-- Specify the port of the web application -->
	<constant name="struts.url.http.port" value="80" />

	<!-- Specify encrypted port-->
	<constant name="struts.url.https.port" value="443" />


    <!-- struts-convention-plugin settings-->
    <!-- Specifies the result page path. The convention plug-in will automatically look for files in this path. The purpose of placing them in WEB-INF is to protect file resources, which can only be accessed by jumping inside the program.
    	  Permission interceptors or other permission processing only need to be added to the action -->
    <constant name="struts.convention.result.path" value="/WEB-INF/pages/"/>
    
    <!-- Set the default parent package. Generally, a default package is set to inherit from struts-default. Most classes then inherit default. If you need a special package, you can only specify the parent package in the action -->
	<constant name="struts.convention.default.parent.package" value="default"/>

	
	<!-- When struts2 is integrated with spring, if Action.class in struts.xml specifies ClassName instead of BeanID,
		Then struts2 is responsible for the creation of the Action object, but the injection of the Action object dependency is responsible for spring.
		struts2 first uses spring to construct Action objects, and uses the name specified by Action.class in struts.xml as the BeanID to find it in spring's applicationContext.xml.
		If you find an Action instance created by spring, it doesn't matter if you don't find it, then struts2 is responsible for constructing this object. However, the autowiring of dependencies still has to be done by spring. -->

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327027918&siteId=291194637