标签:edr tom 输入 https pen @param 部署 lin 乱码
在IDEA环境内嵌Tomcat8正常,在Windows部署的Tomcat8不正常,返回签名错误,原因是tomcat默认的编码使用ISO-8859-1的编码解析器,只要指定HttpServletRequest的读取编码即可解决乱码问题
ServletInputStream inStream = request.getInputStream();
String resp = getStrFromInsByCode(inStream, "utf-8");
/**
*
* @param is 输入流
* @param code 指定读取编码
* @return
*/
public static String getStrFromInsByCode(InputStream is, String code) {
StringBuilder builder = new StringBuilder();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(is, code));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return builder.toString();
}
标签:edr tom 输入 https pen @param 部署 lin 乱码
原文地址:https://www.cnblogs.com/dashi/p/12184609.html