action:(一种绝对路径,一种相对路径都试了)
public java.io.InputStream getInputStream() {
// return ServletActionContext.getServletContext().getResourceAsStream(this.getInputPath());
InputStream stream = null;
try {
stream = new java.io.FileInputStream(this.getInputPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return stream;
}
public String execute() throws Exception {
// String filePath = ServletActionContext.getRequest().getContextPath();
String fullPath = ServletActionContext.getServletContext().getRealPath("/help.chm");
this.setInputPath(fullPath);
setFilename("help.chm");
log.debug("下载帮助.");
return "successDown";
}
xml配置文件:
<action name="downHelp" class="downHelpAction">
<param name="inputPath">${inputPath}</param>
<result name="successDown" type="stream">
<param name="inputName">inputStream</param>
<param name="contentDisposition">attachment;filename=${filename}</param>
</result>
<result name="fileError">error.jsp</result>
</action>
问题:
在我本机一切正常,部署到linux服务器下下载chm文件直接打开里面页面都找不到,下载下来打开也一样。
别人访问我机器(winxp)下载也不行.
但是我自己下下来传给别人他们又能打开.
到底是怎么回事?