[JSP] 屬性檔案要放哪: ResourceBundle.getBundle(...)
※片段程式碼:
Locale userLocale = request.getLocale() ;
ResourceBundle loginBundle = ResourceBundle.getBundle("LogOn", userLocale) ;
loginBundle.getString("welcome")
※說明:
用request.getLocale()取得使用者的語系之後
利用ResourceBundle.getBundle(...)抓到LogOn_zh_TW.properties檔案
供未來的loginBundle.getString("welcome")回傳該語系的welcome字串
※問題:
無法抓到LogOn_zh_TW.properties檔案,會丟出錯誤
我是把LogOn_zh_TW.properties和JSP檔案放在同一個資料夾
請問我應該把LogOn_zh_TW.properties改放到哪裡呢?
※完整JSP內容:
1.連至網址閱讀:
→ http://rafb.net/paste/results/jO2qPr38.html
2.直接在BBS上閱讀:
→ 如下:
<%@ page
contentType="text/html"
import="java.util.*"
%>
<html>
<head><title> International JSP Login Page</title></head>
<body>
<%
Locale userLocale = request.getLocale() ;
ResourceBundle loginBundle = ResourceBundle.getBundle("LogOn", userLocale) ;
%>
<h1> <%= loginBundle.getString("welcome") %> </h1>
<hr/>
<h2> <%= loginBundle.getString("message") %> </h2>
<form>
<input type="text" name="user"/> <%= loginBundle.getString("user") %> <p/>
<input type="text" name="pass"/> <%= loginBundle.getString("passwd") %> <p/>
</form>
</body>
</html>
※錯誤訊息:
.錯誤訊息太冗長,請點選下面的網址閱讀錯誤訊息:
→ http://rafb.net/paste/results/SfOCEb92.html
※補充:
.我是使用Tomcat來架站的:
→ http://jakarta.apache.org/site/downloads/downloads_tomcat-4.html
.如果有需要補上的資訊,歡迎提出來,我會盡我所能的回答。
.在此先謝謝各位的回答了。
※來源:
.JavaTM Web Services - SAMS: Chapter4. P.66~P.67
--
〒作者:H45 來自:15-207.dorm.ncu.edu.tw
◎二進位的世界【140.115.50.50‧binary.csie.ncu.edu.tw】
推
04/10 05:37, , 1F
04/10 05:37, 1F
討論串 (同標題文章)
java 近期熱門文章
PTT數位生活區 即時熱門文章
14
39