问题描述
我有点沮丧,因为我无法通过Struts标记中的 $ {...}
语法找出我可以访问的变量,放在JSP页面中。
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" />
对象在哪里status.menue
必须定义才能使用美元符号和大括号进行访问。它是在另一个struts tile中还是在窗体中定义的?
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?
推荐答案
它应放在任何页面,请求,会话中或者分别使用,,或。您通常直接或间接在Servlet中执行此操作。 MVC框架通过给模型对象提供请求,会话或应用程序范围来间接地执行此操作。
It should be placed in any of the page, request, session or application scopes using respectively JspContext#setAttribute()
, ServletRequest#setAttribute()
, HttpSession#setAttribute()
or ServletContext#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.
将使用。
这一切都与Struts无关。它只是一个基于JSP / Servlet API构建的遗留MVC框架。 < c:set>
不是标记好吧,这是一个标签。
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.
这篇关于在JSP页面的Struts标记中使用$ {...}语法可以访问哪些变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!