current position:Home>Idea uses el and JSTL expressions respectively, which are written in JSP files and display blank space on the web. What's the problem.

Idea uses el and JSTL expressions respectively, which are written in JSP files and display blank space on the web. What's the problem.

2022-02-02 21:27:46 CSDN Q & A

img

The code is as follows :

<%@page import="java.util.HashMap" %><%@ page contentType="text/html;charset=UTF-8" language="java" %><%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%String name=" Trouble ";String sex=" male ";int age=20;HashMap<String,Object> data=new HashMap<String, Object>();data.put("address"," Shanghai ");%><html><head> <title> Data encapsulation and display </title></head><body><h1> The page generates data , use JSP Script to display data </h1><h3> full name :<%=name%><br><%-- Consistent with the variable name above --%> Gender :<%=sex%><br><%-- Consistent with the variable name above --%> Age :<%=age%><br><%-- Consistent with the variable name above --%> Address :<%=data.get("address")%><br><%-- Consistent with the variable name above --%></h3><hr><h1>servlet Generate and encapsulate data , use request Object for data transfer , On the page EL The expression shows the data </h1><h3> user name :${user.username}<br><%--EL expression --%> password :${user.password}<br><%--EL expression --%> Gender :${user.sex}<br><%--EL expression --%> <%-- If the data encapsulated is multi-level structure , Then step by step (user.address.xx) To call --%> Home address :${user.address.province}${user.address.city}${user.address.region}${user.address.rd}<br><%--EL expression --%></h3><hr><h1>servlet Generate data and encapsulate data , use session Object for data transfer , Use on page JSTL Display </h1><h3>ISBN:<c:out value="${book.isbn}" default="no data"/><br> Title :<c:out value="${book.bname}" default="no data"/><br> Price :<c:out value="${book.price}" default="no data"/><br> Press. :<c:out value="${book.press}" default="no data"/><br></h3><hr><h1>servlet Generate data and encapsulate data , use session Object for data transfer , Including circular structure , And use it on the page JSTL Display </h1><h3><c:forEach items="${orderItems}" var="orderItem" ><%--items What follows must be with session The encapsulated object has the same name --%> <%--ot yes orderItem The specific --%> <c:out value="${orderItem.id}" />&nbsp;&nbsp;&nbsp; <c:out value="${orderItem.product.imgUrl}" />&nbsp;&nbsp;&nbsp; <c:out value="${orderItem.product.name}" />&nbsp;&nbsp;&nbsp; <c:out value="${orderItem.product.price}" />&nbsp;&nbsp;&nbsp; <c:choose> <c:when test="${orderItem.num>11}"> <c:out value=" Shortage "/> </c:when> <c:otherwise> <c:out value=" Sell well "/> </c:otherwise> </c:choose> <c:out value="${orderItem.num}" /><br></c:forEach></h3></body></html>



Refer to the answer 1:

1、 No data
2、 There is a problem with conditional judgment




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022127436583.html

Random recommended