mbutu
asked on
Struts <html:errors/>
Hi
I'm trying to use the <html:errors/> tag.
- I have a page where I have put the tag.
<html:errors/>
- In struts-config.xml I have defined the resource bundle for the error messages.
<message-resources parameter="tm-struts-messa ges" null="false"></message-res ources>
- In the Struts action I add the error to the request with the following code.
errors.add(ActionErrors.GL OBAL_ERROR , new ActionError("field.empty") );
if (errors.size() > 0) {
saveErrors(request, errors);
}
- The resource bundle contains the key "field.empty".
- But the problem is that on the page I get the following error message (not the text in the resource bundle):
???en_US.field.empty???
<b>What's the problem?</b>
I'm trying to use the <html:errors/> tag.
- I have a page where I have put the tag.
<html:errors/>
- In struts-config.xml I have defined the resource bundle for the error messages.
<message-resources parameter="tm-struts-messa
- In the Struts action I add the error to the request with the following code.
errors.add(ActionErrors.GL
if (errors.size() > 0) {
saveErrors(request, errors);
}
- The resource bundle contains the key "field.empty".
- But the problem is that on the page I get the following error message (not the text in the resource bundle):
???en_US.field.empty???
<b>What's the problem?</b>
ASKER
Tried it but it did not help.
Hi,
If you are using Struts 1.1, you will need to change the following line
------
<message-resources parameter="tm-struts-messa ges" null="false"></message-res ources>
------
Try to place the resource file under the classes folder, and reference it like a class name as one does it in ResourceBundle class.
E.g.You have placed the file tm-struts-messages.propert ies in ... WEB-INF/classes/com/temp/r esources
then the tage should be like
------
<message-resources parameter="com.temp.resour ces.tm-str uts-messag es"></mess age-resour ces>
------
Hope this helps
Kartik
If you are using Struts 1.1, you will need to change the following line
------
<message-resources parameter="tm-struts-messa
------
Try to place the resource file under the classes folder, and reference it like a class name as one does it in ResourceBundle class.
E.g.You have placed the file tm-struts-messages.propert
then the tage should be like
------
<message-resources parameter="com.temp.resour
------
Hope this helps
Kartik
ASKER
Hi
I've checked and the file is in the /WEB-INF/classes folder.
It's not inside a package so therefore I don't put the package name in front of the file name.
Mbutu
I've checked and the file is in the /WEB-INF/classes folder.
It's not inside a package so therefore I don't put the package name in front of the file name.
Mbutu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are fantastic _marko_ I've never met a Struts expert like you. Thank you so much. Now I won't get fired from the project. Can I send you a small gift. I'm considering a couple of hundred dollars as a gift to you _marko_. For saving me and my family. Do you accept PayPal.
Yours truly
Mbutu and family
Yours truly
Mbutu and family
Hahaha :) You're welcome.
(I know mbutu IRL, he's being sarcastic)
(I know mbutu IRL, he's being sarcastic)
:-D
<servlet>
<servlet-name>action</serv
<servlet-class>org.apache.
bit,
<init-param>
<param-name>application</p
<param-value>tm-struts-mes
</init-param>
and changing:
<message-resources parameter="tm-struts-messa
to
<message-resources parameter="resources.appli
This is the way I've got mine set up, and it seems to work fine :-)
Hope this helps :-)
Tim