使用jspsmart实现文件下载

网上找了个jsmartcom_zh_CN.jar,支持中文,自己试了可以实现,要把server.xml的编码改为gbk( useBodyEncodingForURI="true" URIEncoding="gbk")。发出来给需要的人,也便自己以后使用。

下载类

public ActionForward downLoadFile(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException
{
try
{
String fileName=request.getParameter("fileName");
System.out.println(fileName);
String filePath=request.getParameter("filePath");
System.out.println(filePath);
SmartUpload mySmartUpload = new SmartUpload();
mySmartUpload.initialize(this.servlet.getServletConfig(), request, response);
mySmartUpload.setContentDisposition(null);
mySmartUpload.downloadFile(filePath+fileName);
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}

你可能感兴趣的:(xml,servlet)