楼上的可否说明白一些, 我还是不太明白。系统中存在两个不同的资源文件,浏览器怎么知道哪一个是英文,哪一个是中文,在struts-config.xml中也没有配置 ,很奇怪!!!

解决方案 »

  1.   

    服务器根据locale读取资源,资源名是applicationResources,如locale代表中国则寻找对应的applicationResources_zh.properties
    楼主看下api里的ResourceBundle
      

  2.   

    先看个文件,Locale.java,这个类定义了一些国际化需要的Locale。
          /** Useful constant for language.
         */
        static public final Locale ENGLISH = new Locale("en","","");    /** Useful constant for language.
         */
        static public final Locale FRENCH = new Locale("fr","","");    /** Useful constant for language.
         */
        static public final Locale GERMAN = new Locale("de","","");    /** Useful constant for language.
         */
        static public final Locale ITALIAN = new Locale("it","","");    /** Useful constant for language.
         */
        static public final Locale JAPANESE = new Locale("ja","","");    /** Useful constant for language.
         */
        static public final Locale KOREAN = new Locale("ko","","");    /** Useful constant for language.
         */
        static public final Locale CHINESE = new Locale("zh","","");    /** Useful constant for language.
         */
        static public final Locale SIMPLIFIED_CHINESE = new Locale("zh","CN","");    /** Useful constant for language.
         */
        static public final Locale TRADITIONAL_CHINESE = new Locale("zh","TW","");    /** Useful constant for country.
         */
        static public final Locale FRANCE = new Locale("fr","FR","");    /** Useful constant for country.
         */
        static public final Locale GERMANY = new Locale("de","DE","");    /** Useful constant for country.
         */
        static public final Locale ITALY = new Locale("it","IT","");    /** Useful constant for country.
         */
        static public final Locale JAPAN = new Locale("ja","JP","");    /** Useful constant for country.
         */
        static public final Locale KOREA = new Locale("ko","KR","");    /** Useful constant for country.
         */
        static public final Locale CHINA = new Locale("zh","CN","");    /** Useful constant for country.
         */
        static public final Locale PRC = new Locale("zh","CN","");    /** Useful constant for country.
         */
        static public final Locale TAIWAN = new Locale("zh","TW","");    /** Useful constant for country.
         */
        static public final Locale UK = new Locale("en","GB","");    /** Useful constant for country.
         */
        static public final Locale US = new Locale("en","US","");    /** Useful constant for country.
         */
        static public final Locale CANADA = new Locale("en","CA","");    /** Useful constant for country.
         */
        static public final Locale CANADA_FRENCH = new Locale("fr","CA","");    Struts的国际化是根据用户的浏览器的语言设置来读取不同语言的信息,这个属性就是Locale,这是个全局的,保存在Struts的Session里。也就是说,如果可以动态的更改这个Locale就可以实现一个浏览器动态的读取不同的资源文件了。
        在Action中,我这样做的,
        if(language.equals("01")){
              request.getSession().setAttribute(Globals.LOCALE_KEY, Locale.SIMPLIFIED_CHINESE);
            }else if(language.equals("02")){
              request.getSession().setAttribute(Globals.LOCALE_KEY, Locale.ENGLISH);
            }
        ...............
        这个地方,01代表中文语言,02是英语....
        当用户请求的是中文时,利用
         request.getSession().setAttribute(Globals.LOCALE_KEY, Locale.SIMPLIFIED_CHINESE)将Locale设置为简体中文的,这时候jsp在读取properties文件时,会调用 XXX_zh_CN.properties文件。不同的语言就设置不同的Locale。 只要配好不同语言的文件,就OK了。