异常信息:Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.
struts.xml
<action name="download" class="upload.DownLoadAction"> <param name="inputPath">\WEB-INF\uploadFile\Criteria.txt</param> <result name="success" type="stream"></result> <param name="contentType">text/txt</param> <param name="inputName">downloadFile</param> <param name="contentDisposition">attachment;filename="Criteria.txt"</param> <param name="bufferSize">4096</param> </action>
DownLoadAction.action
package upload; import java.io.FileInputStream; import java.io.InputStream; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class DownLoadAction extends ActionSupport{ private String inputPath; public String getInputPath() { return inputPath; } public void setInputPath(String inputPath) { this.inputPath = inputPath; } //这个getDownloadFile()方法没进入 public InputStream getDownloadFile() { System.out.println("inputPath"+inputPath); System.out.println(ServletActionContext.getServletContext().getResourceAsStream(inputPath)); return ServletActionContext.getServletContext().getResourceAsStream(inputPath); } @Override public String execute() throws Exception { System.out.println("ss"); return SUCCESS; } }
麻烦各位帮我看看,谢谢啦!