Struts2 返回一个为字符串的response

来源:互联网 发布:表白网页源码下载 编辑:程序博客网 时间:2024/06/08 09:42
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
原创粉丝点击