• 每日日报8月21日


    1.今天学习了编写添加界面 addUser.jsp.

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

    <html>

      <head>

        <title>login.jsp页面</title>

      </head>

      <body>

        <form action="loginCL.jsp" method="post" name=form >

         <font size="5">登录界面</font><br>

         用户名:<input type="text" value=""name="username"><br>

         密    码:<input type="text"value="" name="password"><br>

         <input type="submit"value="提交"name="submit">

         <input type="reset"value="重置">   

        </form>

    <%=(String)request.getAttribute("usertxt") %>

      </body>

    </html>

    3.loginCL.jsp文件代码

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

    <html>

      <head>

        <title>loginCL.jsp页面</title>

      </head>

      <body>

    <%

    String referer = request.getHeader("Referer");

    if(referer==null||referer.trim().length()==0||

    !referer.equals("http://localhost:8081/two/login.jsp")){

    response.sendRedirect("login.jsp");

    return;

    }

    request.setCharacterEncoding("utf-8");

    response.setContentType("text/html;charset=utf-8");

    String name=request.getParameter("username");

    String password=request.getParameter("password");

    //判断登陆界面的用户名和密码,根据输入的不同情况进行不同的处理

    if(name.trim().equals("admin")&&password.trim().equals("1234"))

    {

    request.setAttribute("usertxt", "正常登录!!!");

    request.getRequestDispatcher("success.jsp").forward(request, response);

    }

    else{

    request.setAttribute("usertxt", "用户名或密码错误!!!");

    request.getRequestDispatcher("login.jsp").forward(request, response);

    }

    %>

      </body>

    </html>

    4.success.jsp文件代码

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

    <html>

      <head>

        <title>success.jsp页面</title>

      </head>

      <body>

    <%

    String referer = request.getHeader("Referer");

    if(referer==null||referer.trim().length()==0||

    !referer.equals("http://localhost:8081/two/login.jsp")){

    response.sendRedirect("login.jsp");

    return;

    }

    request.setCharacterEncoding("utf-8");

    response.setContentType("text/html;charset=utf-8");

    %>  

    <%=(String)request.getAttribute("usertxt") %>

      </body>

    </html>

    2.没有遇到问题

    3.明天打算学习

    编写添加用户的 Servlet
  • 相关阅读:
    [UE4]Image
    [UE4]CheckBox
    [UE4]Button
    [UE4]Border
    [UE4]RichTextBlock
    [UE4]Text Box
    [UE4]字体材质
    [UE4]Retainer Box
    [UE4]Invalidation Box
    [UE4]Dynamic Entry Box
  • 原文地址:https://www.cnblogs.com/wanghaoning/p/13591725.html
Copyright © 2020-2023  润新知