public ActionForward toExcel(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception { String hiddenHtml = request.getParameter("hiddenHtml");
String fname = request.getParameter("hiddenName");
fname = java.net.URLEncoder.encode(fname, "UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/msexcel");
response.setHeader("Content-Disposition", "attachment;filename=" + fname); PrintWriter out = response.getWriter();
out.println(hiddenHtml); out.flush();
out.close(); return null;这个方法是把从数据库中查询出来的数据导入到excel表中,为什么全部导进去不乱码,而到部分数据进去,却乱码啊?纳闷啊~~
HttpServletResponse response) throws Exception { String hiddenHtml = request.getParameter("hiddenHtml");
String fname = request.getParameter("hiddenName");
fname = java.net.URLEncoder.encode(fname, "UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/msexcel");
response.setHeader("Content-Disposition", "attachment;filename=" + fname); PrintWriter out = response.getWriter();
out.println(hiddenHtml); out.flush();
out.close(); return null;这个方法是把从数据库中查询出来的数据导入到excel表中,为什么全部导进去不乱码,而到部分数据进去,却乱码啊?纳闷啊~~
解决方案 »
- operamasks的w:tree问题
- B/S结构的项目切换输入法时死机
- SSH框架导入struts,hibernate,spring分先后顺序吗>>
- 初学JSP ,一个有关浏览器与服务器时间的问题!
- Struts的Action出空白页面
- linux发布java web项目 路径问题 404
- 找工作,急需java,jsp项目,急急急急急急急!!!!!!!
- tomcat的小问题???帮忙!
- 为什么jsp需要考虑多线程问题,而asp不需要?asp也支持多线程啊?
- tomcat作为web服务器的上传的文件的保存路径问题
- org.hibernate.exception.SQLGrammarException: could not execute query
- 乱码
解决办法:
将response.setCharacterEncoding("UTF-8");
中
UTF-8 改成GBK 就OK 了~~