中文亂碼問題
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% request.setCharacterEncoding("utf-8");
? %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? <head>
? ? <base href="<%=basePath%>">
? ??
? ? <title>My JSP 'session_page1.jsp' starting page</title>
? ??
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> ? ?
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
? </head>
??
? <body>
? <%
? session.setAttribute("username","admin");
? session.setAttribute("password","123456");
? session.setAttribute("habit","play games");
??
? ?%>
? 創(chuàng)建時間:<%=session.getCreationTime() %></br>
? 創(chuàng)建id:<%=session.getId() %></br>
?獲得的屬性 <%=session.getAttribute("username") %></br>
??
??
? </body>
</html>
2017-10-29
request.setCharacterEncoding("UTF-8");?????? 你可以試試看這個
2017-11-01
URL傳參修改tomcat配置config文件