将jsp标记属性传递给Struts 2标记

时间:2013-10-19 10:49:08

标签: jsp struts2 jsp-tags

我在jsp中创建一个名为RequiredLabel的新标签,但是我无法将标签属性传递给struts标签(css基于YAML)

标签将用作:

<myTag:RequiredLabel name="amount"/>

标签应该来自struts,因为它必须本地化。

<%@tag description="Renders a label with required css and error label" pageEncoding="UTF-8"%>
<%@attribute name="name" required="true" %>
<%@taglib prefix="s" uri="/struts-tags"%>

 <!--Here ${name} works fine --> 
<p class="ym-message" id="${name}Error" />
<!-- Here I can not pass the name to s:label tag -->
<s:label key="form.label.%{name}" cssClass="ym-required" />

我尝试了#attr.name#param.name,但没有一个有效!

你知道任何解决方案吗?!

1 个答案:

答案 0 :(得分:0)

我只是想办法做到这一点,但我认为这不是最好的:

<c:set var="labelName" value="form.label.${name}" />
<label class="ym-required"> 
             <s:text name="%{#attr.labelName}" />
</label>

s:label不接受%{#attr.labelName}参数

相关问题