scottlai
元老
发贴: 451
积分: 366
|
于 2002-08-18 21:50
package test; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class ConfResourceBundle extends HttpServlet { public static URLClassLoader confClassLoader = null; public void init() throws ServletException { try { URL confURL[] = { new File(getServletContext().getRealPath("/WEB-INF/conf")).toURL(), }; confClassLoader = URLClassLoader.newInstance(confURL, this.getClass().getClassLoader()); // test ResourceBundle b = getBundle("test.client"); System.out.println(b.getString("NewMessage.Title")); } catch(Exception e) { e.printStackTrace(); } } public static final ResourceBundle getBundle(String baseName) throws MissingResourceException { return getBundle(baseName, Locale.getDefault()); } public static final ResourceBundle getBundle(String baseName, Locale locale) { return getBundle(baseName, locale, confClassLoader); } public static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader) throws MissingResourceException { return ResourceBundle.getBundle(baseName, locale, loader); } }
|