zoukankan      html  css  js  c++  java
  • session

    1,session保存在操作方便,保存在服务器,同样需要setCharacterSet(“UTF—8”)

    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    
    <%@ page import="kooing.People" %>
    <% 
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        People people[]={new People("huanggabin","b",22)
                        ,new People("黄嘎兵","huanggabin",22)
                        ,new People("dsf","famale",22)};
        String message="";
        if(request.getMethod().equals("POST")){
            for(People personA:people){
                if(personA.getName().equals(request.getParameter("name"))&&
                        personA.getPassword().equals(request.getParameter("password"))){
                    session.setAttribute("person",personA);
                    response.sendRedirect(request.getContextPath()+"/welcom.jsp");
                    return;
                }
            }
        }
    %>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <form action="session.jsp" method="post">
                账号:<input type="text" name="name"><br />
                密码: <input type="text" name="password"><br />
                <input type="submit" value="okokok">huan
            </form>
         </body>
    </html>
    View Code
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <jsp:directive.page import="java.util.*"/>
    <jsp:directive.page import="kooing.People"/>
    <%
        People people=(People)session.getAttribute("person");
    %>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
               你的账号:<%=people.getName() %><br/>
               你的密码:<%=people.getName() %><br/>
               你的年龄:<%=people.getAge() %>
         </body>
    </html>
    View Code
  • 相关阅读:
    Python 标准库 urllib2 的使用细节
    为什么C++编译器不能支持对模板的分离式编译
    source insight插件
    tar命令
    绘制和重绘,有效矩形和无效矩形
    常量表达式
    区间迭代
    lambda函数
    decltype和新的返回值语法
    auto用法
  • 原文地址:https://www.cnblogs.com/vhyc/p/6477274.html
Copyright © 2011-2022 走看看