问答详情
源自:4-2 session对象

中文乱码问题

<%@ 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>


提问者:干巴爹forever 2017-10-29 15:33

个回答

  • qq_浅紫色梦境_0
    2017-10-29 20:15:43
    已采纳

    request.setCharacterEncoding("UTF-8");       你可以试试看这个

  • study_everyday
    2017-11-01 23:41:07

    URL传参修改tomcat配置config文件