自定义jstl标记在作为参数传递给spring:message时不起作用

问题描述

我创建了一个自定义标签处理程序来打印当前Year,并创建了它的tld文件。一切看起来都正确,我可以在jsp页面中使用自定义标记,并且如果在任何html标记中或在其外部使用,都可以正常打印当前年份。在spring:message参数中传递时,相同的标记不起作用。下面是我试图通过当前年份作为参数的操作。输出显示{0}占位符

    public class CurrentYearTagHandler extends TagSupport {

    @Override
    public int doStartTag() throws JspException {
        JspWriter out=pageContext.getOut();//returns the instance of JspWriter  
        try{  
            out.print(Calendar.getInstance().get(Calendar.YEAR));  
        }catch(Exception e){System.out.println(e);}  
        return SKIP_BODY;//will not evaluate the body content of the tag  
    }
}

.tld文件

<tlib-version>2.1</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>Current Year</short-name>

<tag>
    <name>currentYear</name>
    <tag-class>com.edmportal.jsp.customtags.CurrentYearTagHandler</tag-class>
</tag>
<spring:message code="layout.footer" arguments="<custom:currentYear></custom:currentYear>"/>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...