当前位置:网站首页>The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
The data in servlet is transferred to JSP page, and the problem cannot be displayed using El expression ${}
2022-07-03 02:16:00 【Grilled little fat sheep with charcoal...】
Problem description : el expression ${} The data of the tag is not displayed on the page .
First look at my servlet and jsp page .
Servlet Code :
@WebServlet(urlPatterns = "/demo1")
public class Servlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 1. Prepare the data
List<Brand> brands = new ArrayList<>();
brands.add(new Brand(1," The three little squirrels "," The three little squirrels ",100," The three little squirrels , It's delicious but not hot ",1));
brands.add(new Brand(2," uniqlo "," uniqlo ",200," uniqlo , Suit life ",0));
brands.add(new Brand(3," millet "," Xiaomi Technology Co., Ltd ",1000," Born with a fever ",1));
// 2. Store in request domain
request.setAttribute("brands", brands);
// 3. Forwarding to el-demo.jsp in
request.getRequestDispatcher("/el-demo.jsp").forward(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
}
}
JSP Code :
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
${brands}
</body>
</html>
Access in a browser :http://localhost:8080/Jsp_demo/demo1, Discover the use of setAttribute Packaged in brands The data in the field is not displayed 
reason :JSP and Servlet Version results in el The function is off by default , Join in <%@page isELIgnored="false"%> Label manual opening el function .
After modification JSP Code :
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%> <%-- Add this tag to start it manually el function --%>
<html>
<head>
<title>Title</title>
</head>
<body>
${brands}
</body>
</html>
Access... Again in the browser :http://localhost:8080/Jsp_demo/demo1, el expression ${} It's normal to show .
边栏推荐
- Cfdiv2 fixed point guessing- (interval answer two points)
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
- The testing process that software testers should know
- stm32F407-------ADC
- File class (add / delete)
- Kotlin middle process understanding and Practice (II)
- 单词单词单词
- [shutter] pull the navigation bar sideways (drawer component | pageview component)
- Flink CDC mongoDB 使用及Flink sql解析monggo中复杂嵌套JSON数据实现
- Method of removing webpage scroll bar and inner and outer margins
猜你喜欢

stm32F407-------DMA

In the face of difficult SQL requirements, HQL is not afraid

使用Go语言实现try{}catch{}finally

Visual yolov5 format data set (labelme JSON file)
![[camera topic] complete analysis of camera dtsi](/img/cb/d42589fcf0610600c9dc8c7992d4d7.png)
[camera topic] complete analysis of camera dtsi

LabVIEW安装第三方VISA软件后NI VISA失效

The technology boss is ready, and the topic of position C is up to you

Learn BeanShell before you dare to say you know JMeter
![[shutter] hero animation (hero realizes radial animation | hero component createrecttween setting)](/img/e7/915404743d6639ac359bb4e7f7fbb7.jpg)
[shutter] hero animation (hero realizes radial animation | hero component createrecttween setting)

MySQL learning 03
随机推荐
人脸识别6- face_recognition_py-基于OpenCV使用Haar级联与dlib库进行人脸检测及实时跟踪
通达OA v12流程中心
LabVIEW安装第三方VISA软件后NI VISA失效
Ni visa fails after LabVIEW installs the third-party visa software
iptables 4层转发
Prohibited package name
Comment le chef de file gère - t - il l'équipe en cas d'épidémie? Contributions communautaires
Learn BeanShell before you dare to say you know JMeter
Modify table structure
require. context
[Yu Yue education] reference materials of love psychology of China University of mining and technology
awk从入门到入土(3)awk内置函数printf和print实现格式化打印
awk从入门到入土(0)awk概述
Socket编程
Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux
udp接收队列以及多次初始化的测试
Unrecognized SSL message, plaintext connection?
Wechat applet development tool post net:: err_ PROXY_ CONNECTION_ Failed agent problem
创建+注册 子应用_定义路由,全局路由与子路由
4. 类和对象