代码:
<@spring.formInput 'myForm.spouseEmail' 'id="spouseEmail" class="text"'/>
<@spring.showErrors ', ' 'error'/>输出:
<span class="error">not a well-formed email address</span>我想要的:
<div class="error">not a well-formed email address</div>发布于 2011-09-08 17:00:59
@Mike:看起来你在理解宏的本质上遇到了麻烦。它们是已经编写的免费标记脚本,让你的生活变得更容易。您可以始终使用write a customed one。
有些人认为这是显而易见的,但我自己发现,要知道如何查看spring-freemarker宏的源代码并不容易。您可以在org/springframework/spring-webmvc-3.0.5.jar/org/springframework/web/servlet/view/freemarker/spring.ftl的“引用的库”中导航到package Eclipse。
这是从“spring.ftl”得到的宏"showErrors“:
<#macro showErrors separator classOrStyle="">
<#list status.errorMessages as error>
<#if classOrStyle == "">
<b>${error}</b>
<#else>
<#if classOrStyle?index_of(":") == -1><#assign attr="class"><#else><#assign attr="style"></#if>
<span ${attr}="${classOrStyle}">${error}</span>
</#if>
<#if error_has_next>${separator}</#if>
</#list>
</#macro>要实现您的目标,非常简单:只需编写一个与上面的代码完全相同的自定义宏,将span替换为div
发布于 2011-06-08 04:18:03
不能,但是你可以很容易地编写你自己的宏来做任何你想做的事情。从spring.showErrors本身获得灵感。
https://stackoverflow.com/questions/6268336
复制相似问题