jsp中文乱码问题?????
<%@ page import="java.io.UnsupportedEncodingException" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%!
String getString(String s){
if (s == null){
s = "";
}
try {
byte[] bytes = s.getBytes("utf-8");
s = new String(bytes,"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return s;
}
%>
<%
String shop = request.getParameter("shop");
session.setAttribute("goods",shop);
%>
<%
String 顾客 = (String) session.getAttribute("customer");
String 姓名 = (String) session.getAttribute("name");
String 商品 = (String) session.getAttribute("goods");
姓名 = getString(姓名);
商品 = getString(商品);
%>
这里是结账处,<%= 顾客%>的姓名是<%= 姓名%>,<br>
你买的商品是<%= 商品%>
</body>
</html>
这里是结账处,顾客的姓名是ææ¬,
你买的商品是çµè§æº
为什么会这样?
rdetrh
2020/11/28 20:34- java
- tomcat
- intellij-idea
- 点赞
- 收藏
- 回答