引用简单标签和 Struts 2.x 的属性
我正在编写一个简单的标签,其中包含 4 个属性,如下所示:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ attribute name="menuName" description="Name of Major Menu" required="true" %>
<%@ attribute name="menuSize" description="Number of Items In Menu" required="true" type="java.lang.Integer" %>
<%@ attribute name="menuImage" description="Icon for Image" required="true" %>
<%@ attribute name="menuNumber" description="Order of Positioning" required="true" %>
Struts 2 标签内有一个点,我需要引用这些属性之一,如下所示:
<s:set name="it" value="%{#application['tools'][${menuName}]}" />
所以你看,我正在基于 OGNL 表达式进行查找传入的菜单名称是什么。从我看到的所有示例中,EL 是引用属性 menuName 的常用方式,但在 Struts 2.x 中,出于安全原因,EL 被禁用。
有没有办法引用我需要引用的属性。我真的不想考虑任何涉及我使用以前版本的 jstl 或 struts 的解决方案。
I am writing a simple tag which contains 4 attributes like so:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ attribute name="menuName" description="Name of Major Menu" required="true" %>
<%@ attribute name="menuSize" description="Number of Items In Menu" required="true" type="java.lang.Integer" %>
<%@ attribute name="menuImage" description="Icon for Image" required="true" %>
<%@ attribute name="menuNumber" description="Order of Positioning" required="true" %>
There is a point within a Struts 2 tag that I need to make reference to one of these attributes like so:
<s:set name="it" value="%{#application['tools'][${menuName}]}" />
So you see I am doing a lookup in the OGNL expression based upon what the menu name which was passed in. From all the examples I see, EL is the common way of referencing the attribute menuName, but in Struts 2.x EL is disabled for security reasons.
Is there a way to reference the attribute I need to reference. I really do not want to consider any solution which involves me going to previous versions of jstl or struts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以前从来不知道#attr,多么简洁
Never knew about the #attr before, how neat