67,513
社区成员
发帖
与我相关
我的任务
分享
<action name="exportexcel" class="BeenChina.PM.Action.CaseNumberEfficiencyQuery">
<result name="success" type="stream">
...
<param name="contentDisposition">attachment;filename="${fileName}.xls"</param>
...
</result>
</action>
public String getFileName() throws UnsupportedEncodingException {
fileName=new String(fileName.getBytes(),"ISO8859-1");
return fileName;
}
public void setFileName(String fileName) throws UnsupportedEncodingException {
this.fileName=fileName;
}
public static String encode(HttpServletRequest request, String fileName) throws UnsupportedEncodingException {
String agent = request.getHeader("USER-AGENT" );
if( null != agent && - 1 != agent.indexOf( "MSIE" )) {
return URLEncoder.encode(fileName, "UTF8" );
}
else if ( null != agent && - 1 != agent.indexOf( "Firefox" )) {
return "=?UTF-8?B?" +( new String(Base64.encodeBase64(fileName.getBytes( "UTF-8" ))))+ "?=" ;
}
else if ( null != agent && - 1 != agent.indexOf( "Chrome" )) {
return new String(fileName.getBytes(), "ISO8859-1");
}
else{
return fileName;
}
}
好用是好用了,不知道这样做合适不?