以下配置在windows下可以下载 在linux下无法下载....
struts.xml
<action name="down" class="downloadAction">
${inputPath}
<result name="successDown" type="stream">
inputStream
attachment;filename=${filename}
</result>
<result name="fileError">error.jsp</result>
</action>
action:
public java.io.InputStream getInputStream() {
InputStream stream = null;
try {
stream = new java.io.FileInputStream(this.getInputPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return stream;
}
public String execute() throws Exception {
this.setInputPath(cmsOfflineResources.getResourcePath());
setFilename(downloadname + filetype);
return "successDown";
}
//get set 方法省略
报错 无法找到 inputStream:
javax.servlet.ServletException: java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the tag specified for this action.
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
struts2在windows下可以下载 在linux下报错
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-