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

Struts2 返回一个为字符串的response

2013-10-30 22:41 197 查看
package actions;
import java.io.InputStream;
import java.io.StringBufferInputStream;
import com.opensymphony.xwork2.ActionSupport;
public class TextResultAction extends ActionSupport {
private InputStream inputStream;
public InputStream getInputStream() {
return inputStream;
}
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
public String execute() throws Exception {
inputStream = new StringBufferInputStream(
"Hello World! This is a text string response from a Struts 2 Action.");
return SUCCESS;
}
}
<action name="text-result" class="actions.TextResultAction">
<result type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>

转自:http://blog.sina.com.cn/s/blog_530bf5d20100c15o.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐