标签:
action:
package web; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; import entity.Deposit; import service.DepositService; //file:///D:/iProgram/JAVA/toolsJar/struts2/struts-2.3.20/docs/docs/ajax.html public class DepositAction extends AbstractAction<Deposit, DepositService> { InputStream inputStream; public String transaction() throws UnsupportedEncodingException { inputStream = new ByteArrayInputStream(service.transaction().toString() .getBytes("UTF-8")); return SUCCESS; } @Override public String getAll() { // TODO Auto-generated method stub return null; } @Override public String save() { return null; } @Override public void prepareSave() { // TODO Auto-generated method stub } @Override public String delete() { // TODO Auto-generated method stub return null; } @Override public String findById() { // TODO Auto-generated method stub return null; } @Override public String update() { // TODO Auto-generated method stub return null; } @Override public void prepareUpdate() { // TODO Auto-generated method stub } public InputStream getInputStream() { return inputStream; } public void setInputStream(InputStream inputStream) { this.inputStream = inputStream; } }
<action name="deposit-*" class="DepositAction" method="{1}"> <result type="stream"> <param name="contentType">text/html</param> <param name="inputName">inputStream</param> </result> </action>
<param name="inputName">inputStream</param>
这里的inputStream 和 action中的变量名要相同,并且提供getter
标签:
原文地址:http://blog.csdn.net/tragedyxd/article/details/45151245