Getting java.util.Calendar.YEAR in Spring message code

假如想象 提交于 2019-12-25 01:55:32

问题


<spring:message code="footer.copyriteText" arguments="NEEDS TO BE DYNAMIC" htmlEscape="false"/>

I need to replace NEEDS TO BE DYNAMIC with Calendar.getInstance().get(Calendar.YEAR). How can I achieve this using EL?


回答1:


If you don't want hardcode solution like BalusC said you can use this solution

  1. Write custom jstl tag like c:set to execute constant path and return constant value then put the constant value to Page scope. This can be done via java Reflection.

  2. Use the tag

    <lib:getConstant path='java.util.Calendar.YEAR' var='v'/>
    

And

arguments='${v}`

This solution can work with all constants and you may want change constant values without changing jsp code.



来源:https://stackoverflow.com/questions/20436627/getting-java-util-calendar-year-in-spring-message-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!