gpt4 book ai didi

java - 无法显示隐式 EL(表达式语言)范围对象

转载 作者:行者123 更新时间:2023-12-02 06:33:05 24 4
gpt4 key购买 nike

我已将 servlet 'SetAttributes' 创建为,

request.setAttribute("a1","v1");
HttpSession session=request.getSession();
session.setAttribute("a2","v2");
ServletContext application=getServletContext();
application.setAttribute("a3","v3");
request.setAttribute("c","request");
session.setAttribute("c","session");
application.setAttribute("c","application");

RequestDispatcher rd=request.getRequestDispatcher("Process.jsp");
rd.forward(request, response);

现在Process.jsp如下,

a1, a2, a3 can be directly accessed as: ${a1} ${a2} ${a3}<br />

Each attribute can also be accessed as: ${requestScope.a1} ${sessionScope.a2} ${applicationScope.a3}<br />

Accessing the repeated attribute directly then the value will be for: ${c}<br />
Common attribute can also be accessed as: ${requestScope.c} ${sessionScope.c} ${applicationScope.c}<br />

Trying to access out of scope attribute we get: ${applicationScope.a1}

属性的值,即“a1”、“a2”和“a3”应该显示在我的网页上,但我得到的是空白值。

下面是我的 Process.jsp 输出,

a1, a2, a3 can be directly accessed as: 
Each attribute can also be accessed as:
Accessing the repeated attribute directly then the value will be for: Common attribute can also be accessed as:
Trying to access out of scope attribute we get:

感谢任何帮助。

最佳答案

您直接访问 JSP,无需通过设置所有属性的 servlet。很明显,当JSP执行时,所有属性都为空。

地址栏中的 URL 必须是 servlet 的 URL,而不是 JSP 的 URL。

关于java - 无法显示隐式 EL(表达式语言)范围对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19903901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com