看板java
标 题[JSP] 属性档案要放哪: ResourceBundle.getBundle(...)
发信站中大资工二进位的世界 (Mon Apr 10 01:45:22 2006)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news.ncu!news.csie.ncu!BinaryBBS
※片段程式码:
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】
1F:推 ogamenewbie:. 04/10 05:37