读书人

ResourceBundle种

发布时间: 2012-10-13 11:38:17 作者: rapoo

ResourceBundle类

package TestI18N;import java.io.IOException;import java.io.PrintWriter;import java.util.Locale;import java.util.ResourceBundle;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class TestResourceBundle extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {                 ResourceBundle resource=ResourceBundle.getBundle("resouce_ch");    String key="key";    String message =resource.getString(key);    System.out.println(message);    String key1="key1";    String message1 =resource.getString(key1);        System.out.println(message1);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {            doGet(request, response);}}


在ResourceBundle加载的资源文件resource_ch.properties要放在WEB-INF的classes的目录下,一直存放在WEB-INF下会出错? why?

读书人网 >Web前端

热点推荐