[英]How make struts2 see my properties file
嗨,我有這個項目結構
在我的index.jsp
我有這個代碼:
<%@ 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沒有從我的屬性文件中獲取信息。 請告訴我我錯了什么我在互聯網上找不到任何有用的東西請幫助我謝謝=)
您的屬性文件需要位於WEB-INF
下的classes
目錄或classes
目錄的子目錄中。
假設您有這個結構.../Web-INF/classes/property/content.properties
,您需要在struts.xml
執行此操作
<constant name="struts.custom.i18n.resources" value="property.content" />
首先將content.properties
重命名為global_en.properties
。 后來把它放在src
文件夾中
您已完成所有操作,但尚未保留屬性文件名作為操作名稱。 名稱應為Login.property。
另外,請確保屬性文件必須與正在創建的Action對象包在同一個包中。
有關詳細信息,請參閱以下鏈接:
http://struts.apache.org/release/2.2.x/docs/message-resource-files.html
謝謝,Shahid Saeed Khan
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.