在文件下載的時候,一般是這麼配置
<result type="stream" name="download">
<param name="contentDisposition">attachment;filename="${filename}"</param>
<param name="inputName">downloadFile</param>
</result>
但是,如果filename裏有中文的話,就會造成獲取到的名字爲亂碼.但是不報錯..
解決這個的方法是
public String download()
{
TextInfo ti = textInfoService.findById(Integer.valueOf(id));
try
{
this.setFilename(new String(ti.getFilename().getBytes(),"ISO8859-1"));
} catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
return "download";
}