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

4
  • So you want me to change it every year for copyright year ? Commented Dec 7, 2013 at 9:41
  • Can you explain more ? Calendar.getInstance().get(Calendar.YEAR) is what actually I am refering to. Commented Dec 7, 2013 at 9:53
  • What issue you see ? and whats your recommended solution ? Commented Dec 7, 2013 at 10:58
  • My problem is not really with the expected outcome of Calendar.YEAR , but how to use a "dynamic" value out of java classes to use in Spring Commented Dec 7, 2013 at 11:07

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.