【问题标题】:Passing jsp tag attribute to Struts 2 tags将 jsp 标签属性传递给 Struts 2 标签
【发布时间】:2013-10-19 10:49:08
【问题描述】:

我正在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,但都没有奏效!

你知道解决办法吗?!

【问题讨论】:

    标签: jsp struts2 jsp-tags


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-04
      • 2012-01-29
      • 2012-08-22
      • 1970-01-01
      • 2013-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多