• 每日日报2020 11/29


    package shiyan1;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import shiyan1.Dao;
    import shiyan1.Bean;


    /**
    * Servlet implementation class addServlet
    */
    @WebServlet("/addServlet")
    public class addServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public addServlet() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    //response.getWriter().append("Served at: ").append(request.getContextPath());
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");

    String ID=request.getParameter("username");
    HttpSession session=request.getSession();
    session.setAttribute("ID", ID);//存储数据
    request.setAttribute("ID", ID);
    String password=request.getParameter("password");
    String method=request.getParameter("profession");

    if("1".equals(method)) {
    try{
    System.out.println(1);

    if("123456".equals(ID)&&"654321".equals(password)) {
    response.getWriter().println("<script type='text/javascript'> alert('登录成功')</script>");
    request.getRequestDispatcher("manage.jsp").forward(request, response);}
    else {
    response.getWriter().println("<script type='text/javascript'> alert('密码或账号错误')</script>");
    request.getRequestDispatcher("shenfen.jsp").forward(request, response);}
    }catch(Exception e){
    System.out.println("失败");
    e.printStackTrace();
    }
    }

  • 相关阅读:
    【计算机网络】第三章 数据链路层
    【网页设计】第四周 JavaSript
    【计算机网络】第二章 物理层
    【计算机网络】第一章 概述
    [寒假学习]ps知识
    [蓝桥杯]算法提高 GPA
    用Java模拟游戏重力的实现(弹跳)
    【狼叔分享】狼叔20年上半年故事分享
    旷视教会我如何安装tensorflow环境|这才是真正的pip install tensorflow
    大学逆袭的三步骤:大三实习、大四秋招、大四春招
  • 原文地址:https://www.cnblogs.com/song-1/p/14177092.html
Copyright © 2020-2023  润新知