i remember a class is used to get the effect.try by yourself.and searth information from the net.

解决方案 »

  1.   

    以下代码是读取info.properties属性文件的参数。测试环境jdk1.4import java.util.ResourceBundle;public class EnvPara
    {
    private static ResourceBundle resources = null; public static void init()
    {
    if(resources == null)
    {
    resources = ResourceBundle.getBundle("info");
    }
    } public static String getString(String sName)
    {
    String sResult = null;
    try
    {
    init();
    sResult = resources.getString(sName);
    }
    catch(Exception e)
    {
    e.printStackTrace();
    sResult = null;
    }
    return sResult;
    } public static void main(String[] args)
    {
    System.out.println("test:"+EnvPara.getString("TEST"));
    }
    }
      

  2.   

    本想发例子,被 alphafish(alphafish) 抢了先。:)
      

  3.   

    按照 alphafish(alphafish) 提供的示例,补充一下:info.properties文件放置在WEB-INF\classes目录下,内容有一行为:
    TEST=abcdefg
    #-----------
    System.out.println("test:"+EnvPara.getString("TEST")); // 主键为TEST,输出“abcdefg”
      

  4.   

    如果info.properties文件放置在WEB-INF\classes目录下:
      ResourceBundle.getBundle("info");如果info.properties文件放置在WEB-INF\classes\com\yaray\config目录下:
      ResourceBundle.getBundle("com.yaray.config.info");
      ResourceBundle.getBundle("com/yaray/config/info");
    任意一个均可
      

  5.   

    你看看CNJSP1.2 论坛的源代码,里面有很详尽的属性文件操作方法!在www.cnjsp.com上可以找到,很好的开源项目!