struts2 下载中文文件名称乱码,可以下载
struts
-------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts2" extends="struts-default">
<action name="uploadAction" class="com.lkw.action.UploadAction">
<result name="success">showfile.jsp</result>
</action>
<action name="downloadfile2" class="com.lkw.action.DownloadAction2">
<result name="success" type="stream">
<param name="contentDisposition">attachment;filename=${filename}</param>
<param name="inputName">downloadFile</param>
</result>
</action>
</package>
</struts>
-----------------------------------------------
action
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class UploadAction extends ActionSupport {
private File file;
private String fileFileName;//获取文件名,命名规则为:filename+FileName
private String fileContentType;//获取文件的类型,命名规则为:filename+ContentType
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;