如何让struts2看到我的属性文件 [英] How make struts2 see my properties file
问题描述
我有这个项目结构
,在我的index.jsp
中,我有以下代码:
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>
我的content.property
文件如下所示:
index.hello = Hello user./n/r Please login
index.login = Login
index.password = Password
index.title = Login Page
并且当我启动项目时,struts2没有从我的属性文件中获取信息. 请告诉我我做错了什么 我在互联网上找不到任何有用的信息 请帮帮我 谢谢=)
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 =)
推荐答案
您的属性文件必须位于WEB-INF
下的classes
目录中或classes
目录的子目录中.
Your properties file needs to be in the your classes
directory under WEB-INF
or a sub-directory of classes
directory.
让我们假设您具有这种结构
.../Web-INF/classes/property/content.properties
,
您将需要在struts.xml
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" />
这篇关于如何让struts2看到我的属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!