How to make struts2 see my properties file

Hi, I have this project structure.

enter image description here

and in mine index.jspI 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.propertyfile is as follows:

index.hello = Hello user./n/r Please login
index.login = Login
index.password = Password
index.title = Login Page

and when I run the project struts2 does not get information from my properties file. please tell me what I did wrong I can not find anything useful on the Internet Help me please thanks =)

+5
source share
3 answers

Your properties file must be in a directory classesin WEB-INFor in a subdirectory of a directory classes.

Suppose you have this structure .../Web-INF/classes/property/content.properties you will need to do this instruts.xml

<constant name="struts.custom.i18n.resources" value="property.content" />

+6
source

content.properties global_en.properties. src

+2

You did everything right, but you did not save the property file name with the name Action. The name should be Login.property.

Also make sure that the properties file must be in the same package as the action created against it.

See the following link for more details:

http://struts.apache.org/release/2.2.x/docs/message-resource-files.html

Thanks, Shahid Saeed Khan

+1
source

All Articles