Struts1关于struts-config.xml中的controller标签
官方文档对于controller的描述为:
The <controller>
element allows you to configure the ActionServlet. Many of the controller parameters were previously defined by servlet initialization parameters in your web.xml
file but have been moved to this section of struts-config.xml
in order to allow different modules in the same web application to be configured differently.
翻译:
<controller>标签允许我们配置ActionServlet。大多数的控制器参数,都在web.xml文件中由servlet初始化参数预先配置好了;但是在struts-config.xml中(通过controller标签)配置这些参数的意义在于:一个web应用中的不同模块可以通过多种方式进行配置;
的确,controller标签中可以有多种属性可以进行配置
- bufferSize - The size (in bytes) of the input buffer used when processing file uploads. [4096] (optional)
- catalog - Name of the catalog to use when processing requests for this module. [struts]
- className - Classname of configuration bean. [org.apache.struts.config.ControllerConfig] (optional)
- command - Name of the command to execute to process a request. [servlet-standard]
- contentType - Default content type (and optional character encoding) to be set on each response. May be overridden by the Action, JSP, or other resource to which the request is forwarded. [text/html] (optional)
- forwardPattern - Replacement pattern defining how the "path" attribute of a
<forward>
element is mapped to a context-relative URL when it starts with a slash. This value may consist of any combination of the following:- $M - Replaced by the module prefix of this module.
- $P - Replaced by the "path" attribute of the selected
<forward>
element. - $$ - Causes a literal dollar sign to be rendered.
- $x - (Where "x" is any character not defined above) Silently swallowed, reserved for future use.
- inputForward - Set to
true
if you want theinput
attribute of<action>
elements to be the name of a local or globalActionForward
, which will then be used to calculate the ultimate URL. Set tofalse
to treat theinput
parameter of<action>
elements as a module-relative path to the resource to be used as the input form. [false] (optional) - locale - Set to
true
if you want aLocale
object stored in the user's session if not already present. [true] (optional) - maxFileSize - The maximum size (in bytes) of a file to be accepted as a file upload. Can be expressed as a number followed by a "K", "M", or "G", which are interpreted to mean kilobytes, megabytes, or gigabytes, respectively. [250M] (optional)
- memFileSize - The maximum size (in bytes) of a file whose contents will be retained in memory after uploading. Files larger than this threshold will be written to some alternative storage medium, typically a hard disk. Can be expressed as a number followed by a "K", "M", or "G", which are interpreted to mean kilobytes, megabytes, or gigabytes, respectively. ["256K"]
- multipartClass - The fully qualified Java class name of the multipart request handler class to be used with this module. [org.apache.struts.upload.CommonsMultipartRequestHandler] (optional)
- nocache - Set to
true
if you want the controller to add HTTP headers for defeating caching to every response from this module. [false] (optional) - pagePattern - Replacement pattern defining how the
page
attribute of custom tags using it is mapped to a context-relative URL of the corresponding resource. This value may consist of any combination of the following:- $M - Replaced by the module prefix of this module.
- $P - Replaced by the "path" attribute of the selected
<forward>
element. - $$ - Causes a literal dollar sign to be rendered.
- $x - (Where "x" is any character not defined above) Silently swallowed, reserved for future use.
- processorClass - The fully qualified Java class name of the
RequestProcessor
subclass to be used with this module. [org.apache.struts.chain.ComposableRequestProcessor] (optional) - tempDir - Temporary working directory to use when processing file uploads. [{the directory provided by the servlet container}]