在用struts2做下载的时候,
这是struts.xml部分代码: <action name="download" class="downloadAction">
<result name="success" type="stream">
<param name="fileName"></param>
<param name="contentDisposition">
attachment;filename="${downloadFileName}"
</param>
<param name="inputName">downloadFile</param>
</result>
</action>这是Action代码:package com.struts2.action;import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.interceptor.ServletRequestAware;import com.opensymphony.xwork2.ActionSupport;public class DownloadAction extends ActionSupport implements
ServletRequestAware {
private HttpServletRequest request;
private String fileName; public void setServletRequest(HttpServletRequest request) {
this.request = request;
} public InputStream getDownloadFile() {
File file = new File(request.getSession().getServletContext()
.getRealPath("/")
+ fileName);
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return fis;
} @Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return super.execute();
} public String getDownloadFileName() {
String downloadFileName = fileName;
try {
downloadFileName = new String(downloadFileName.getBytes(),
"iso8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return downloadFileName;
} public String getFileName() {
return fileName;
} public void setFileName(String fileName) {
this.fileName = fileName;
}
}
现在遇到的问题就是,在我单独用struts2做的时候没什么问题,但是加入spring之后,<param name="contentDisposition">
attachment;filename="${downloadFileName}"
</param>就得不到文件名的返回值,请各位大虾支招,该怎么处理啊?