I am generating a word document from HTML using docx4j, but I am not able to set the downloaded file name. By default it picks the servlet name as WordDocGenServlet.docx.
Any help ??
Thanks in advance!
You can. Set the reponse header with your file name. Something like this
fileName = dateString+"_マイページ情報.xls";
fileName = URLEncoder.encode(fileName,"UTF-8");
try {
response.setContentType("application/ms-excel; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
if(browserType.equals("IE")||browserType.equals("Chrome"))
response.setHeader("Content-Disposition","attachment; filename="+fileName);
if(browserType.endsWith("Firefox"))
response.setHeader("Content-Disposition","attachment; filename*=UTF-8''"+fileName);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.