我沒有問題,加載和使用從位於網站的根JSP
文件properties
文件(使用ResourceBundle
類),但是當我嘗試從它位於一個JSP
加載相同properties
文件目錄失敗,並說資源無法找到!頁面JSP資源包
代碼位於目錄中的
<%@page import="org.apache.log4j.Logger"%>
<%@page import="com.persiangulfcup.utility.LogUtils"%>
<%@page import="java.util.ResourceBundle"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
Logger logger = LogUtils.getLogger("page/contact");
ResourceBundle lbls = null;
ResourceBundle msgs = null;
try {
lbls = ResourceBundle.getBundle("labels");
msgs = ResourceBundle.getBundle("messages");
} catch (Exception ex) {
logger.fatal(ex);
}
%>
<div class="form">
<div style="text-align: left; font: normal bold 14px arial; cursor: pointer" onclick="contactBox.hide();">X</div>
<div style="padding-bottom: 10px;font-size: 14px; text-align: center"><%=msgs.getString("contactHeader")%></div>
<form id="frmContact" onsubmit="try {sendContact();} catch (e) {console.log(e)} return false;">
<table class="form">
<tr>
<td class="caption"><%=lbls.getString("name")%>: </td>
<td class="data">
<input id="txtName" type="text" name="txtName"/>
</td>
</tr>
<tr>
<td class="caption"><%=lbls.getString("email")%>: </td>
<td class="data">
<input id="txtEmail" type="text" name="txtEmail"/>
</td>
</tr>
<tr>
<td class="caption"><%=lbls.getString("subject")%>: </td>
<td class="data">
<input id="txtSubject" type="text" name="txtSubject"/>
</td>
</tr>
<tr>
<td class="caption"><%=lbls.getString("message")%>: </td>
<td class="data">
<textarea id="txtMessage" name="txtMessage"></textarea>
</td>
</tr>
<tr>
<td class="button" colspan="2"><input type="submit" value="<%=lbls.getString("send")%>"/></td>
</tr>
<tr>
<td style="text-align: center" colspan="2" id="brdContact"></td>
</tr>
</table>
</form>
</div>
顯示代碼.. – Bozho
Eeeek,scriptlets。使用JSTL fmt。 http://stackoverflow.com/questions/4276061/how-to-internationalize-a-java-web-application – BalusC