EL+JSTL 替换项目中的 JSP代码

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值