{{format('0')}} {{format('748')}} {{format('1131')}}

纯 jsp 实现登录 [ 编程杂谈 ]

大数据男孩 文章 正文

想做一个技术博客,奈何实力不够
分享

明妃

{{nature("2022-08-14 17:23:14")}}更新

项目结构

在这里插入图片描述


00x0设置首页(web.xml)

<welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
</welcome-file-list>

00x1 首页表单

<form action="do_login.jsp" method="post">
    <div><p>账号:</p><input type="text" id="account" name="account"></div>
    <div><p>密码</p><input type="text" id="pwd" name="pwd"></div>
    <div><input type="submit"></div>
</form>

00x2 逻辑处理页(do_login.jsp)

<%
    String username = request.getParameter("account");
    String pwd = request.getParameter("pwd");

    if(username.equals("admin") && pwd.equals("123")){
        session.setAttribute("username",username);
        response.sendRedirect(request.getContextPath()+"/success.jsp");
    }else{
        session.setAttribute("username",username);
        response.sendRedirect(request.getContextPath()+"/failure.jsp");
    }
%>

00x3 登录成功页于失败同理

<h1>登录成功,<%=session.getAttribute("username") %></h1>

结果展示

在这里插入图片描述

评论 0
0
{{userInfo.data?.nickname}}
{{userInfo.data?.email}}
TOP 2
Spark 2.0 单机模式与集群模式 安装

{{nature('2020-01-02 16:47:07')}} {{format('12518')}}人已阅读

TOP 3
Office 2016 Pro Plus 激活

{{nature('2019-12-11 20:43:10')}} {{format('9407')}}人已阅读

TOP 4
Linux上 MySQL 开启远程登陆的两种方法

{{nature('2019-12-26 17:20:52')}} {{format('7400')}}人已阅读

TOP 5
Linux 安装 MySQL 5.7

{{nature('2019-12-26 16:03:55')}} {{format('4877')}}人已阅读

目录

标签云

jsp 登录 表单

一言

# {{hitokoto.data.from || '来自'}} #
{{hitokoto.data.hitokoto || '内容'}}
作者:{{hitokoto.data.from_who || '作者'}}
自定义UI
配色方案

侧边栏