当前位置:网站首页>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 .
边栏推荐
- 我的创作纪念日
- Machine learning notes (constantly updating...)
- My creation anniversary
- Anna: Beibei, can you draw?
- Awk from entry to burial (1) awk first meeting
- es6 filter() 数组过滤方法总结
- How to deal with cache hot key in redis
- Machine learning process and method
- Unrecognized SSL message, plaintext connection?
- Recommendation letter of "listing situation" -- courage is the most valuable
猜你喜欢
返回一个树形结构数据
内存池(内核角度理解new开辟空间的过程)
Distributed transaction solution
Introduce in detail how to communicate with Huawei cloud IOT through mqtt protocol
The testing process that software testers should know
Asian Games countdown! AI target detection helps host the Asian Games!
Coroutinecontext in kotlin
《上市风云》荐书——唯勇气最可贵
创建+注册 子应用_定义路由,全局路由与子路由
Recommendation letter of "listing situation" -- courage is the most valuable
随机推荐
Socket编程
Unrecognized SSL message, plaintext connection?
stm32F407-------IIC通讯协议
Coroutinecontext in kotlin
微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
Trial setup and use of idea GoLand development tool
CFdiv2-Fixed Point Guessing-(区间答案二分)
y54.第三章 Kubernetes从入门到精通 -- ingress(二七)
Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
[Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China
What are the key points often asked in the redis interview
Depth (penetration) selector:: v-deep/deep/ and > > >
DML Foundation
CFdiv2-Fixed Point Guessing-(區間答案二分)
詳細些介紹如何通過MQTT協議和華為雲物聯網進行通信
Visualisation de l'ensemble de données au format yolov5 (fichier labelme json)
力扣(LeetCode)183. 从不订购的客户(2022.07.02)
His experience in choosing a startup company or a big Internet company may give you some inspiration
awk从入门到入土(3)awk内置函数printf和print实现格式化打印
UDP receive queue and multiple initialization test