您的位置:首页 > 编程语言 > Java开发

Struts2 result type(结果类型)

2012-04-06 10:55 471 查看
在struts2框架中,当action处理完之后,就应该向用户返回结果信息,该任务被分为两部分:结果类型和结果本身。

结果类型提供了返回给用户信息类型的实现细节。结果类型通常在Struts2中就已预定义好了(见下表),或者是由插件提供,开发人员也可以自定义结果类型。默认配置的结果类型是dispatcher,该结果类型使用JSP来向用户显示结果。当定义了结果类型之后,该结果类型可以在不同的action中重复使用。

Struts2框架提供的结果类型

已配置结果类型名类  名描  述
dispatcherorg.apache.struts2.dispatcher.

ServletDispatcherResult
默认结果类型,用来呈现JSP页面
chaincom.opensymphony.xwork2.

ActionChainResult
将action和另外一个action链接起来
freemarkerorg.apache.struts2.views.freemarker.

FreemarkerResult
呈现Freemarker模板
httpheaderorg.apache.struts2.dispatcher.

HttpHeaderResult
返回一个已配置好的HTTP头信息响应
redirectorg.apache.struts2.dispatcher.

ServletRedirectResult
将用户重定向到一个已配置好的URL
redirectActionorg.apache.struts2.dispatcher.

ServletActionRedirectResult
将用户重定向到一个已定义好的action
streamorg.apache.struts2.dispatcher.

StreamResult
将原始数据作为流传递回浏览器端,

该结果类型对下载的内容和图片非常有用
velocityorg.apache.struts2.dispatcher.

VelocityResult
呈现Velocity模板
xsltorg.apache.struts2.views.xslt.

XSLTResult
呈现XML到浏览器,

该XML可以通过XSL模板进行转换
plaintextorg.apache.struts2.dispatcher.

PlainTextResult
返回普通文本类容
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息