I'm new to JSP, trying to implement a Resource Bundle to put all the labels on my jsp page. Here's what I got.
I put this file labels.properties
into WEB-INF/classes
:
greeting=Hello!
And put this into my .jsp page:
<fmt:setBundle basename="labels" var="labels" scope="application"/>
<fmt:message key="greeting" bundle="${ labels }"/>
I see Hello!
on the page, all is fine. But what if I want to put it into resources folder? Say I want this structure resources/bundles/labels.properties
. I tried to change setBundle to this:
<fmt:setBundle basename="resources.bundles.labels" var="labels" scope="application"/>
But it didn't work. I also tried adding this to my web.xml which didn't help either:
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.bundles.labels</param-value>
</context-param>
I suppose I'm missing something. My resources folder is in Java Build Path but I still cannot hook any file from it as a resource bundle. Sorry if this is something easy and stupid, I really tried to find some solution to this here and on Google and what I posted above is all I've managed to come to :(