Resource set value as a template in Date format

I want to read the template for JST formatDate also from a set of resources, but this naive approach does not work, what am I doing wrong?

in com / company / MyPortlet.properties is the key:

company.date.format = yyyy-MM-dd HH:mm:ss 

On the page I:

 <fmt:setBundle basename="com.company.MyPortlet"/> <fmt:formatDate value="${date}" pattern="${company.date.format}" /> 
+4
source share
1 answer

You need to pass the package the variable name.

 <fmt:setBundle basename="com.company.MyPortlet" var="bundle" /> 

This path is available on the ${bundle} page. You can receive fmt:message messages, and you can use its var attribute to store it in the local area. Then you can use it in the pattern fmt:formatDate attribute fmt:formatDate

 <fmt:message bundle="${bundle}" key="company.date.format" var="pattern" /> <fmt:formatDate value="${date}" pattern="${pattern}" /> 
+5
source

Source: https://habr.com/ru/post/1310521/


All Articles