当前位置:网站首页>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 .
边栏推荐
- COM and cn
- 可视化yolov5格式数据集(labelme json文件)
- Pytorch convolution network regularization dropblock
- What are MySQL locks and classifications
- 5.文件操作
- Basic operation of view
- 内存池(内核角度理解new开辟空间的过程)
- Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
- 深度(穿透)选择器 ::v-deep/deep/及 > > >
- stm32F407-------ADC
猜你喜欢

Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux
![[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor](/img/06/ab333a4752de27eae2dd937cf579e2.png)
[Flutter] dart: class; abstract class; factory; Class, abstract class, factory constructor

His experience in choosing a startup company or a big Internet company may give you some inspiration

A 30-year-old software tester, who has been unemployed for 4 months, is confused and doesn't know what to do?

udp接收队列以及多次初始化的测试

Deep learning notes (constantly updating...)

Trial setup and use of idea GoLand development tool

How to deal with cache hot key in redis

RestCloud ETL 跨库数据聚合运算

Machine learning notes (constantly updating...)
随机推荐
Hard core observation 547 large neural network may be beginning to become aware?
Visualisation de l'ensemble de données au format yolov5 (fichier labelme json)
MySQL learning 03
Method of removing webpage scroll bar and inner and outer margins
udp接收队列以及多次初始化的测试
Iptables layer 4 forwarding
PyTorch 卷积网络正则化 DropBlock
The testing process that software testers should know
Detailed analysis of micro service component sentinel (hystrix)
Visual yolov5 format data set (labelme JSON file)
How do browsers render pages?
2022 spring "golden three silver four" job hopping prerequisites: Software Test interview questions (with answers)
Reprint some Qt development experience written by great Xia 6.5
Where is the future of test engineers? Confused to see
leetcode961. Find the elements repeated N times in the array with length 2n
[Yu Yue education] Jiujiang University material analysis and testing technology reference
Unrecognized SSL message, plaintext connection?
COM and cn
Learn BeanShell before you dare to say you know JMeter
Missing library while loading shared libraries: libisl so. 15: cannot open shared object file: No such file