---
title: "《研磨struts2》附录A Struts2的配置 之 A.1 struts.xml的配置  "
author: "研磨struts2"
date: "2012-07-09T12:10:03Z"
tags: []
categories: ["企业架构"]
slug: "struts2-a-struts2-a-1-struts-xml"
draft: false
lastmod: "2012-07-09T12:10:03Z"
id: 1582443
url: "https://rubbing-struts2.iteye.com/blog/1582443"
---

## A.1  struts.xml的配置

### []()A.1.1  概述

前面已经分散学习了Struts2的各部分知识，相应的配置也分散到相关部分去学习了，这里再把这些配置的知识梳理和总结一下，以利于大家更好的掌握。

       Struts2的配置文件主要是struts.xml文件，以前还有一个struts.properties文件，现在struts.properties文件的内容基本上都可以在struts.xml文件进行配置，也就不再重要了。

### []()A.1.2  DOCTYPE和根元素

       struts.xml文件必须包含如下的DOCTYPE的定义，如果是struts-2.0的dtd，示例代码如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;?xml version="1.0" encoding="UTF-8" ?&gt;
2. &lt;!DOCTYPE struts PUBLIC
3. "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
4. "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;

如果是struts-2.1的dtd，示例代码如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;?xml version="1.0" encoding="UTF-8" ?&gt;
2. &lt;!DOCTYPE struts PUBLIC
3. "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
4. "http://struts.apache.org/dtds/struts-2.1.dtd"&gt;

struts.xml文件的根元素是&lt;struts&gt;，它的dtd定义是：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT struts ((package|include|bean|constant)\*, unknown-handler-stack?)&gt;

unknown-handler-stack：这个是2.1的dtd加入的，用来配置当找不到某些资源的时候进行处理的处理器的栈。

### []()A.1.3  package元素

用来逻辑上组织Struts的配置，这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT package (result-types?, interceptors?, default-interceptor-ref?, default-action-ref?, default-class-ref?, global-results?, global-exception-mappings?, action\*)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/07da0ec88688aaa4de275febcf30ddec__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;package name="hello" namespace="/javass" extends="struts-default"&gt;

### A.1.4  action元素

action元素用来配置一个动作，这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT action (param|result|interceptor-ref|exception-mapping)\*&gt;

![](http://sishuok.com/forum/upload/2012/4/27/212cf0aa40653ba83414f12608908ccd__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;action name="helloworldAction" class="cn.javass.hello.struts2impl.action.HelloWorldAction" method="create"&gt;

### A.1.5  include元素

include元素用来引入其他相关模块的struts配置文件。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT include (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/d5e8d6856b8b44880694db13c4f4442c__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;struts&gt;
2. &lt;include file="struts-user.xml"/&gt;
3. &lt;include file="struts-dep.xml"/&gt;
4. ……
5. &lt;/struts&gt;

### []()A.1.6  bean元素

bean元素用来配置一个bean，可以是由Struts来创建这个bean，也可以是使用给定bean的静态方法。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT bean (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/87d0725addaa159b08e9738ca37aeba2__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;bean class="com.opensymphony.xwork2.ObjectFactory" name="xwork" /&gt;

### []()A.1.7  constant元素

constant元素用来覆盖在default.properties文件里面配置的常量值。有了constant元素就不必再去配置struts.properties文件了，把struts.properties里面的配置，直接使用constant元素配置到struts.xml里面。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT constant (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/71a72af2abe5ad1d1198fae715dd5415__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;bean name="um" type=”UserEbi” class="cn.javass.vo.UserModel"&gt;

### []()A.1.8  unknown-handler-stack元素

unknown-handler-stack元素用来配置当找不到某些资源的时候进行处理的处理器的栈。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT unknown-handler-stack (unknown-handler-ref\*)&gt;

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;bean type="com.opensymphony.xwork2.UnknownHandler" name="handler1" class="com.opensymphony.xwork2.config.providers.SomeUnknownHandler"/&gt;
2. &lt;bean type="com.opensymphony.xwork2.UnknownHandler" name="handler2" class="com.opensymphony.xwork2.config.providers.SomeUnknownHandler"/&gt;
3. &lt;unknown-handler-stack&gt;
4. &lt;unknown-handler-ref name="handler1" /&gt;
5. &lt;unknown-handler-ref name="handler2" /&gt;
6. &lt;/unknown-handler-stack&gt;

### []()A.1.9  unknown-handler-ref元素

unknown-handler-ref元素用来参照处理器。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT unknown-handler-ref (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/94fef1123ff1c74e9f76ea01d4825fac__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;bean type="com.opensymphony.xwork2.UnknownHandler" name="handler1" class="com.opensymphony.xwork2.config.providers.SomeUnknownHandler"/&gt;
2. &lt;unknown-handler-stack&gt;
3. &lt;unknown-handler-ref name="handler1" /&gt;
4. &lt;/unknown-handler-stack&gt;

### []()A.1.10  default-action-ref元素

default-action-ref元素用来配置默认的动作，如果在package里面找不到与当前URL对应的多座，那么就调用这个action。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT default-action-ref (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/4bc4ac0f767665b78e3acce944e18688__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;default-action-ref name=”helloAction”/&gt;

### []()A.1.11  default-interceptor-ref元素

default-interceptor-ref元素用来配置默认的拦截器或拦截器栈，如果在action里面没有明确的定义或引用拦截器或拦截器栈，那么就调用这里配置的拦截器或拦截器栈。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT default-interceptor-ref (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/40e08a680194689c91c42c4dea197afc__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;default-interceptor-ref name="defaultStack"/&gt;

### []()A.1.12  default-class-ref元素

default-class-ref元素用来配置默认的类，如果没有为某个Action指定具体的class值时，将自动引用这个默认的类。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT default-class-ref (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/e3497433acb1a93758eff78f712ab025__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;default-class-ref class="cn.javass.action.DefaultAction"/&gt;

### []()A.1.13  exception-mapping元素

exception-mapping元素用来配置处理动作没有处理的例外。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT exception-mapping (#PCDATA|param)\*&gt;

![](http://sishuok.com/forum/upload/2012/4/27/81e7fe81c5cb4fb69975615110d34d7c__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;action name="helloworldAction" class="cn.javass.action.action.HelloWorldAction"&gt;
2. &lt;exception-mapping result="math-exception" exception="java.lang.ArithmeticException"/&gt;
3. &lt;exception-mapping result="math-exception" exception="java.lang.Exception"/&gt;
4. &lt;result name="math-exception"&gt;/error.jsp&lt;/result&gt;
5. &lt;result&gt;/s2impl/welcome.jsp&lt;/result&gt;
6. &lt;/action&gt;

### []()A.1.14  global-exception-mapping元素

global-exception-mappings元素用来配置公共的exception-mapping，可以包含1到多个的exception-mapping元素。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT global-exception-mappings (exception-mapping+)&gt;

### []()A.1.15  global-results元素

global-results元素用来配置公共的result，可以包含1到多个的result元素。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT global-results (result+)&gt;

### []()A.1.16  interceptor元素

interceptor元素用来配置拦截器。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT interceptor (param\*)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/ceaca469af0e03aa085e738f4b8cdf9f__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;package name="helloworld"  extends="struts-default"&gt;
2. &lt;interceptors&gt;
3. &lt;interceptor name=“myInterceptor” class="cn.javass.action.action.MyInterceptor"/&gt;
4. &lt;/interceptors&gt;
5. ……
6. &lt;/package&gt;

### A.1.17  interceptor-ref元素

interceptor-ref元素用来应用拦截器或拦截器栈。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT interceptor-ref (param\*)&gt;

它有如下的属性：

![](http://sishuok.com/forum/upload/2012/4/27/23566c280529fc556d960e5acc00272e__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;action name="helloworldAction" class="cn.javass.action.action.HelloWorldAction"&gt;
2. &lt;result name="toWelcome"&gt;/s2impl/welcome.jsp&lt;/result&gt;
3. &lt;interceptor-ref name=“myInterceptor”/&gt;
4. &lt;interceptor-ref name="defaultStack"/&gt;
5. &lt;/action&gt;

       要注意：在Action里面配置了拦截器的引用，会覆盖掉默认的配置，因此通常需要再手动的引用defaultStack。

### A.1.18  interceptor-stack元素

interceptor-stack元素用来配置拦截器栈。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT interceptor-stack (interceptor-ref\*)&gt;

它有如下的属性：

![](http://sishuok.com/forum/upload/2012/4/27/1a9707f22e49684ce0d737bdd0196936__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;interceptor-stack name="defaultStack"&gt;
2. &lt;interceptor-ref name="exception"/&gt;
3. &lt;interceptor-ref name="alias"/&gt;
4. ……
5. &lt;/interceptor-stack&gt;

### []()A.1.19  interceptors元素

interceptors元素用来包装多个拦截器。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT interceptors (interceptor|interceptor-stack)+&gt;

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

01. &lt;interceptors&gt;
02. &lt;interceptor name="alias" class="com.opensymphony.xwork2.interceptor.AliasInterceptor"/&gt;
03. &lt;interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/&gt;
04. ……
05. &lt;interceptor-stack name="basicStack"&gt;
06. &lt;interceptor-ref name="exception"/&gt;
07. &lt;interceptor-ref name="servletConfig"/&gt;
08. &lt;interceptor-ref name="prepare"/&gt;
09. &lt;interceptor-ref name="checkbox"/&gt;
10. &lt;interceptor-ref name="multiselect"/&gt;
11. &lt;interceptor-ref name="actionMappingParams"/&gt;
12. &lt;interceptor-ref name="params"&gt;
13. &lt;param name="excludeParams"&gt;dojo\\..\*,^struts\\..\*&lt;/param&gt;
14. &lt;/interceptor-ref&gt;
15. &lt;interceptor-ref name="conversionError"/&gt;
16. &lt;/interceptor-stack&gt;
17. ……
18. &lt;/interceptors&gt;

### A.1.20  param元素

param元素用来嵌套在其他元素中，为这些元素设置参数，比如：action、result-type、interceptor等等。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT param (#PCDATA)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/2ce6216af5c67f232b2fa114aa5e6bec__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;result name="toWelcome" type="dispatcher"&gt;
2. &lt;param name="location"&gt;/s2impl/welcome.jsp&lt;/param&gt;
3. &lt;param name="parse"&gt;true&lt;/param&gt;
4. &lt;/result&gt;

### []()A.1.21  result元素

result元素用来为action指定结果。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT result (#PCDATA|param)\*&gt;

![](http://sishuok.com/forum/upload/2012/4/27/a3a4fc7980ca5dca78b410c2dd9d9e57__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;result name="toWelcome" type="dispatcher"&gt;/welcome.jsp&lt;/result&gt;

### []()A.1.22  result-type元素

result-type元素用来注册结果类型，也就是具体处理结果的类。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT result-type (param\*)&gt;

![](http://sishuok.com/forum/upload/2012/4/27/0394595e14d855d0631aa3b8211c6b82__%E6%9C%AA%E5%91%BD%E5%90%8D.jpg)

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/&gt;

### []()A.1.23  result-types元素

result-types元素用来包含一个到多个result-type的定义。这个元素的dtd定义如下：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;!ELEMENT result-types (result-type+)&gt;

简单的配置示例：

 

java代码：

[查看](http://sishuok.com/forum/blogPost/list/4191.html)[复制到剪贴板](http://sishuok.com/forum/blogPost/list/4191.html)[打印](http://sishuok.com/forum/blogPost/list/4191.html)

1. &lt;result-types&gt;
2. &lt;result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/&gt;
3. &lt;result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/&gt;
4. ......
5. &lt;/result-types&gt;

 

 

私塾在线网站原创《[研磨struts2](http://sishuok.com/forum/blogCategory/showByCategory.html?categories_id=81&user_id=5948)》系列

转自请注明出处：【[http://sishuok.com/forum/blogPost/list/0/4191.html](http://sishuok.com/forum/blogPost/list/0/4191.html)】

欢迎访问[http://sishuok.com](http://sishuok.com/)获取更多内容