开发者

Why would applying a cssClass to a s:label create two labels in Struts 2?

Any thoughts on why this...

<s:label label="%{getText('userDetails')}" cssClass="headerLabel"/>

results in this..

<label class="label" for="">User Details:</label>
<label id="" class="headerLabel"><开发者_JS百科/label>


Apparently this is just what the <s:label> tag does. There is no way I can find to apply css to the first part though.


Which version of struts are you using (2.2.1)?

Did you try to change your label directive to:

<s:label label="%{getText('userDetails')}" cssClass="headerLabel" theme="simple"/>

If it still doesn't work create a new file called label.ftl inside your WEB-INF/classes/template/simple/ application folder with this content:

<label<#rt/>
<#if parameters.id??>
 id="${parameters.id?html}"<#rt/>
</#if>
<#if parameters.cssClass??>
 class="${parameters.cssClass?html}"<#rt/>
</#if>
<#if parameters.cssStyle??>
 style="${parameters.cssStyle?html}"<#rt/>
</#if>
<#if parameters.title??>
 title="${parameters.title?html}"<#rt/>
</#if>
<#if parameters.for??>
 for="${parameters.for?html}"<#rt/>
</#if>
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
<#include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" />
><#rt/>
<#if parameters.nameValue??>
<@s.property value="parameters.nameValue"/><#t/>
</#if>
</label>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜