Hi I have this project structure
and in my index.jsp
I have this code:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>
<s:text name="index.title" />
</title>
</head>
<body>
<s:form action="Login">
<s:textfield key="index.login" name="login" />
<s:password key="index.password" name="password" />
<s:submit/>
</s:form>
</body>
</html>
my content.property
file looks like this:
index.hello = Hello user./n/r Please login
index.login = Login
index.password = Password
index.title = Login Page
and when i start the project, struts2 is not getting info from my property file. please tell me what i made wrong I can't find anything helpful on the internet help me please thanks =)
Your properties file needs to be in the your classes
directory under WEB-INF
or a sub-directory of classes
directory.
Let's assume that you have this structure
.../Web-INF/classes/property/content.properties
,
you will need to do this in your struts.xml
<constant name="struts.custom.i18n.resources" value="property.content" />
First rename your content.properties
to global_en.properties
. Later put it in src
folder
You have done all things OK but you have not kept the property file name as of the Action name . The name should be Login.property.
Also please make sure that the property file must be in the same package as of the Action against it is being created.
Please refer the following link for details:
http://struts.apache.org/release/2.2.x/docs/message-resource-files.html
Thanks, Shahid Saeed Khan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With