index.jsp代码
<%@ page import="com.qiku.entity.User" %><%--
Created by IntelliJ IDEA.
User: Lingray
Date: 2022/5/17
Time: 23:35
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
User user = (User) session.getAttribute("user");
%>
<c:if test="${user!=null}">
<c:out value="欢迎登录,欢迎+${user.getUsername()}"></c:out>
</c:if>
<c:if test="${user==null}">
<h1><a href="login.jsp"><c:out value="立即登录"></c:out></a></h1>
<h1><a href="register.jsp"><c:out value="注册"></c:out></a></h1>
</c:if>
</body>
</html>
login.jsp代码
<%--
Created by IntelliJ IDEA.
User: Lingray
Date: 2022/5/17
Time: 23:52
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<form action="login" method="post">
用户名:<input type="text" name="username"> <br>
密码:<input type="password" name="password"><br>
<span style="color: red">
${"error"== null ? "" : "error"}
</span>
<input type="submit" value="立即登录">
</form>
</form>
</body>
</html>
register.jsp代码
<%--
Created by IntelliJ IDEA.
User: Lingray
Date: 2022/5/17
Time: 23:53
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<form action="register" method="post">
用户编号:<input type="text" name="id"><br>
用户名:<input type="text" name="username"> <br>
密码:<input type="password" name="password"><br>
联系方式:<input type="text" name="telephone"><br>
生日:<input type="text" name="birthday"><br>
性别:<input type="text" name="sex"><br>
<span style="color: red">
${"error" == null ? "":"error"}
</span>
<input type="submit" value="立即注册">
</form>
</body>
</html>
logout.jsp代码
<%--
Created by IntelliJ IDEA.
User: Lingray
Date: 2022/5/18
Time: 0:03
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<a href="logout">退出登录</a>
</body>
</html>