Novice User
Novice User

Reputation: 3824

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

<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?

Upvotes: 0

Views: 826

Answers (1)

LHA
LHA

Reputation: 9655

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.

Upvotes: 1

Related Questions