JSP 页面中 Struts 标记中的 ${...} 语法可以访问哪些变量?
我有点沮丧,因为我无法找出可以使用放置在 JSP 页面中的 Struts 标记中的 ${...}
语法访问哪些变量。
作为一个例子,我有以下代码:
<c:set target="${status.menue}" property="activeMenuePath" value="whatever" />
必须在哪里定义对象 "status.menue"
才能使用美元符号和大括号进行访问。它是在另一个 struts 磁贴中还是在表单中定义的?
I'm getting a little bit frustrated since I can't find out which variables I can access with the ${...}
syntax in a Struts tag, placed in a JSP page.
As an example I've got the following code:
<c:set target="${status.menue}" property="activeMenuePath" value="whatever" />
Where does the object "status.menue"
have to be defined in order to can be accessed with a dollar sign and braces. Is it defined in another struts tile or in the form?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该分别使用
JspContext#setAttribute()
,ServletRequest#setAttribute( )
,HttpSession#setAttribute()
或ServletContext#setAttribute()
。通常,您可以在 Servlet 内直接或间接地执行此操作。 MVC 框架间接地做到这一点,通常可以通过为模型对象提供“请求”、“会话”或“应用程序”范围来配置。表达式语言 (EL) 将使用
JspContext #findAttribute()
。顺便说一句,这一切都与 Struts 无关。它只是一个构建在 JSP/Servlet API 之上的遗留 MVC 框架。
也不是一个 Struts 标签,它是一个 JSTL 标记。It should be placed in any of the page, request, session or application scopes using respectively
JspContext#setAttribute()
,ServletRequest#setAttribute()
,HttpSession#setAttribute()
orServletContext#setAttribute()
. You normally do that either directly or indirectly inside a Servlet. MVC frameworks do that indirectly, usually configureable by giving the model object a "request", "session" or "application" scope.The Expression Language (EL) will access them using
JspContext#findAttribute()
.This all is by the way unrelated to Struts. It's just a legacy MVC framework which is built on top of the JSP/Servlet API. The
<c:set>
is not a Struts tag as well, it's a JSTL tag.