I am trying to read a "properties file" form JSTL using taglib , but i can't access it
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
I've located the tld file correctly in the web.xml , am sure of this
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/lib/fmt.tld</taglib-location>
</taglib>
The properties file name is msg. properties
<fmt:bundle basename="msg">
<fmt:message key="error.more" />
</fmt:bundle>
I keep getting
???error.more???
instead of the message in properties file
I think the problem is either in locating the properties file , or in the base name in
<fmt:bundle basename="msg">
where should I locate the properties file , and how can I make a reference to it in the code??
thanks everyone
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
This is the wrong URI. This is for the old JSTL 1.0 which is out of life for long. For JSTL 1.1 you should be using http://java.sun.com/jsp/jstl/fmt
.
I've located the tld file correctly in the web.xml , am sure of this
<taglib> <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri> <taglib-location>/WEB-INF/lib/fmt.tld</taglib-location> </taglib>
This is unnecessary when you fix the taglib URL. Remove it from your web.xml
and remove all those loose TLD files as well. You should just have jstl.jar
and standard.jar
in /WEB-INF/lib
. Or when you're using JSTL 1.2, just the jstl-1.2.jar
. Nothing more needs to be done.
The properties file name is msg. properties
<fmt:bundle basename="msg"> <fmt:message key="error.more" /> </fmt:bundle>
I keep getting
???error.more???
instead of the message in properties file I think the problem is either in locating the properties file , or in the base name in
<fmt:bundle basename="msg">
where should I locate the properties file, and how can I make a reference to it in the code?
Put it in the classpath. In your particular case, with the base name msg
, you need to put the msg.properties
files in the root of the classpath.