struts2中常用的返回类型有:
1. Chain(chain) 构成一条动作链
2.Dispatcher(dispatcher) 默认类型,转发
3.FreeMarker(freemarker) 用于与FreeMarker的集成
4.HttpHeader(httpheader) 把HTTP标头发送回用户
5.Redirect(redurect) 重定向到另一个URL
6.RedirectAction(redirectAction) 重定向到另一个Action
7.Stream(stream) 把一个InputStream流发送给浏览器(下载用)
8.Velocity(Velocity) 用于与Velocity技术的集成
9.XSLT(xslt) 用于与XML/XSLT技术的集成
10.PlainText(plaintext) 发送普通文本,通常用来显示JSP页面的源代码
自定义一个返回类型 json
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult"><param name="excludeProperties">[a-zA-Z][a-zA-Z0-9]*Service</param>
<param name="ignoreHierarchy">false</param>
</result-type>
</result-types>
返回json类型 其中result、pageResource为变量
<global-results>
<result name="ajax" type="json">
<param name="root">
result
</param>
</result>
<result name="page" type="json">
<param name="root">
pageResource
</param>
</result>
<result name="errorPage">
/WEB-INF/jsp/error.jsp
</result>
</global-results>