页面用ext js做的、
这个是点击下载时把文件名传入后台
window.location.href = '/portal/download.do?method=download&downFlag=1&fileName='+ fileName;后台Action代码
public ActionForward download(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) {
String classPath = null;
try {
classPath = java.net.URLDecoder.decode(
Global.downloadEnv.getPath(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
classPath = Global.downloadEnv.getPath();
}
DownloadTool dt = new DownloadTool();
dt.setDownLoadDir(classPath);
String downloadFileName = request.getParameter("fileName");
if(downloadFileName.indexOf("../") == -1){
String decodeStr = new String(downloadFileName);
try {
downloadFileName = new String(downloadFileName
.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
downloadFileName = decodeStr;
}
dt.downLoadFile(downloadFileName, response);
}
return null;
}windows环境下士好用的 但是到了linux下文件名有中文的就没有响应了,求高手赐教,小弟不胜感激!!
这个是点击下载时把文件名传入后台
window.location.href = '/portal/download.do?method=download&downFlag=1&fileName='+ fileName;后台Action代码
public ActionForward download(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) {
String classPath = null;
try {
classPath = java.net.URLDecoder.decode(
Global.downloadEnv.getPath(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
classPath = Global.downloadEnv.getPath();
}
DownloadTool dt = new DownloadTool();
dt.setDownLoadDir(classPath);
String downloadFileName = request.getParameter("fileName");
if(downloadFileName.indexOf("../") == -1){
String decodeStr = new String(downloadFileName);
try {
downloadFileName = new String(downloadFileName
.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
downloadFileName = decodeStr;
}
dt.downLoadFile(downloadFileName, response);
}
return null;
}windows环境下士好用的 但是到了linux下文件名有中文的就没有响应了,求高手赐教,小弟不胜感激!!
解决方案 »
- JDBC 批量存储问题。
- ibatis配置问题
- 我想在我的jsp网页上出现一个这样的效果 希望前辈赐教!!
- tomcat如何实现重新加载class
- Hql有问题吗,不解?
- servlet 问题 急!请各位高手指点迷津!
- 对访问者模式(Visitor)的疑问?
- 在线请问如何用javascript 来设置jsp页面的 struts的hidden控件的值
- 小弟的毕业设计是web service集成.net和j2ee应用 ,请大侠给点意见
- 有没有用jbuilder7+weblogic7+sqlserver2000的朋友?有一个问题请教
- s:checkbox怎么在表格中排版?
- java实现zip压缩后的压缩文件无内容怎么办???
有一种可能是容器使用的默认编码为linux平台的默认编码,可能不是ISO-8859-1,所以没有转换。你就取不到文件了。有一个办法是修改容器(tomcat或weblogic)的编码。其他的等高手给你解决吧