---
title: "Struts2返回结果类型"
author: "jslfl"
date: "2013-04-03T15:35:17Z"
tags: []
categories: ["开源软件"]
slug: "struts2"
draft: false
lastmod: "2013-04-03T15:35:17Z"
id: 1841524
url: "https://jslfl.iteye.com/blog/1841524"
---

转自：http://blog.csdn.net/sleeping_/article/details/6583425

Struts2提供了对不同种类返回结果的支持，常见的有JSP，FreeMarker，Velocity等。

struts.xml配置文件中result的语法：<result name="" type="">xxxxx</result>

Struts2支持的不同类型的返回结果为：

Chain Result-->type="chain"
用来处理Action链

Dispatcher Result -->type="dispatcher"
用来转向页面，通常处理JSP

FreeMarker Result -->type="freemarker"
处理FreeMarker模板

HttpHeader Result -->type="httpheader"
用来控制特殊的Http行为

Redirect Result -->type="redirect"
重定向到一个URL

Redirect Action Result -->type="redirectAction"
重定向到一个Action

Stream Result -->type="stream"
向浏览器发送InputSream对象，通常用来处理文件下载

Velocity Result -->type="velocity"
处理Velocity模板

XLST Result -->type="xslt"
处理XML/XLST模板

PlainText Result -->type="plainText"
显示原始文件内容，例如文件源代码