The local tomcat is normal, but the content is garbled when downloading liunx poi excel

青灯夜游
Release: 2018-10-17 15:14:26
forward
3191 people have browsed it

This article will introduce to you the solution to the problem that the local tomcat is normal, but the content is garbled when downloading liunx poi excel. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Conclusion: Just add out.clear to jsp (the premise is to ensure that the generated excel is correct on the server, and garbled characters appear only when the browser transmits it).

dowload.jsp complete code

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="com.userpackage.*" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request. setCharacterEncoding("UTF-8");
//response.setHeader("Content-Type", "charset=UTF-8");
%>

<%
/*
Enumeration pNames = request.getParameterNames();
String keyStr="";
String valueStr="";
Map map = new HashMap();

while (pNames.hasMoreElements()) {
	keyStr = pNames.nextElement().toString();
	valueStr = request.getParameter(keyStr).toString().trim();
	if(!"".equals(valueStr)){
		out.println(keyStr+"=="+valueStr);
	}
}
*/out.clear();out = pageContext.pushBody();
ExcelExport.export(request,response);

out.println("22222");
%>
Copy after login

Phenomenon:

response.reset();// Add in servlet to clear the blank line in the header

The above is the detailed content of The local tomcat is normal, but the content is garbled when downloading liunx poi excel. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template