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
Struts2 返回一个为字符串的response
最新推荐文章于 2019-06-10 10:07:29 发布