<%@ 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");
%>
创建时间:<%=session.getCreationTime() %></br>
创建id:<%=session.getId() %></br>
获得的属性 <%=session.getAttribute("username") %></br>
</body>
</html>
request.setCharacterEncoding("UTF-8"); 你可以试试看这个
URL传参修改tomcat配置config文件