没用过你这种写法,你可以看下官方文档。我给你提供几种方案返回结果用streampublic class TextResult extends ActionSupport {
private InputStream inputStream;
public InputStream getInputStream() {
return inputStream;
}
public String execute() throws Exception {
inputStream = new ByteArrayInputStream("Hello World! This is a text string response from a Struts 2 Action.".getBytes("UTF-8"));
return SUCCESS;
}
}
text/html
inputStream
对于简单的字符串,手动拼就可以了
2.使用json插件
具体可以查看文档
3.使用gson等一些第三方jar包,配合1