EL and use JSTL

Original link: https://www.mk2048.com/blog/blog.php?id=h0jcj0aai1aa&title=EL+%E5%92%8C+JSTL+%E7%9A%84%E4%BD%BF%E7%94%A8

HE

Express Language Expression Language

Is to <java language written here%%> jsp wording of this embodiment becomes simplified in $ {}

E.g

action="${pageContext.request.contextPath }/login"

 

JSTL is JSP Standard Tag Library is the JSP Standard Tag Library

(Jsp java server pages is actually a Servlet

在C:\apache-tomcat-9.0.4-windows-x64\apache-tomcat-9.0.4\work\Catalina\localhost\sunwei_Test02\org\apache\jsp

 View jsp of java files

 

 

)

For example

The if statement only if there is no else, when needed again if the use of a copy source code into two if implemented in two different display the same page

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <center>
        <c:if test="${empty user }">
        <h2><a href="login.jsp">登录</a></h2>
        <h2><a href="linkman_save.jsp">新增联系人</a></h2>
        </c:if>
        <c:if test="${not empty user }">
        <h2><span style="color:red;">欢迎:${user.username }</span></h2>
        <h2><a href="linkman_save.jsp">新增联系人</a></h2>
        </c:if>
    </center>
</body>
</html>

 


More professional front-end knowledge, make the [2048] ape www.mk2048.com

Guess you like

Origin blog.csdn.net/qq_45670012/article/details/102752739