Jsp Access Resource Kit

  Abstract: Access Resource Kit jsp 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="736" border="0"> <tr> <td width = " 730 "> </ td> </ tr> </ table> 

  Write a tool categories: 

  Package jsfdb.model; import java.util.ResourceBundle; import java.util.MissingResourceException; import java.util.logging.Level; import java.util.logging.Logger; public class ModelUtils (/ / attention to how to access resources attribute documents location 
  Public static final String RESOURCES = ModelUtils.class.getPackage (). GetName () +. "Res.ModelResources"; private static ResourceBundle resources; public static void log (Throwable x) (Logger.global.log (Level.SEVERE, x . getMessage (), x);) public static synchronized ResourceBundle getResources () (if (resources == null) (try ResourceBundle.getBundle resources = (RESOURCES);) catch (MissingResourceException x) (log (x); throw new InternalError (x.getMessage ());) return resources;) 
  Public static String getResource (String key) (return getResources (). GetString (key);)) 

  Calling in JSP: 

  <% @ Page contentType = "text / html; GBK charset ="%> 
  <% @ Page import = "java.util.Locale"%> 
  <% @ Page import = "jsfdb.model .*"%> 
<%
  String s2 = ModelUtils.getResource ( "indexWindowTitle"); 

  String s3 = ModelUtils.getResource ( "indexPageTitle"); 

  Out.println ( "window title =" + + s2 " 
");
  Out.println ( "page title =" + + s3 " 
");

  Out.println (ModelUtils.RESOURCES); 
%>

  The result: 

  Window Title = = JSF test page headline Please fill in the following information 
  Jsfdb.model.res.ModelResources 

  Attachment: ModelResources_zh_CN.properties 
  JSF indexWindowTitle = \ u6d4b \ u8bd5 
  IndexPageTitle = \ u8bf7 \ u586b \ u5199 \ u4e0b \ u5217 \ u7684 \ u4fe1 \ u606f 

  </ Td> </ tr> <tr> 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply