zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然轻量级JAVA EE企业应用开发Struts2Sping4Hibernate整合开发学习笔记:Spring_I18N

    <?xml version="1.0" encoding="GBK"?>
    <project name="spring" basedir="." default="">
        <property name="src" value="src"/>
        <property name="dest" value="classes"/>
    
        <path id="classpath">
            <fileset dir="../../lib">
                <include name="**/*.jar"/>
            </fileset>
            <pathelement path="${dest}"/>
        </path>
    
        <target name="compile" description="Compile all source code">
            <delete dir="${dest}"/>
            <mkdir dir="${dest}"/>
            <copy todir="${dest}">
                <fileset dir="${src}">
                    <exclude name="**/*.java"/>
                </fileset>        
            </copy>
            <javac destdir="${dest}" debug="true" includeantruntime="yes"
                deprecation="false" optimize="false" failonerror="true">
                <src path="${src}"/>
                <classpath refid="classpath"/>
                <compilerarg value="-Xlint:deprecation"/>
            </javac>
        </target>
    
        <target name="run" description="Run the main class" depends="compile">
            <java classname="lee.SpringTest" fork="yes" failonerror="true">
                <classpath refid="classpath"/>
            </java>
        </target>
    
    </project>
    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
        <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
            <!-- 驱动Spring调用messageSource Bean的setBasenames()方法,
                该方法需要一个数组参数,使用list元素配置多个数组元素 -->
            <property name="basenames">
                <list>
                    <value>message</value>
                    <!-- 如果有多个资源文件,全部列在此处 -->
                </list>
            </property>
        </bean>
    </beans>
    hello=欢迎你,{0}
    now=现在时间是:{0}
    hello=welcome,{0}
    now=now is :{0}
    hello=u6b22u8fceu4f60uff0c{0}
    now=u73b0u5728u65f6u95f4u662fuff1a{0}
    package lee;import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;import java.util.*;
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    public class SpringTest
    {
        public static void main(String[] args)throws Exception
        {
            // 实例化ApplicationContext
            ApplicationContext ctx = new
                ClassPathXmlApplicationContext("beans.xml");
            // 使用getMessage()方法获取本地化消息。
            // Locale的getDefault方法返回计算机环境的默认Locale
            String hello = ctx.getMessage("hello" , new String[]{"孙悟空"}
                , Locale.getDefault(Locale.Category.FORMAT));
            String now = ctx.getMessage("now" , new Object[]{new Date()}
                , Locale.getDefault(Locale.Category.FORMAT));
            // 打印出两条本地化消息
            System.out.println(hello);
            System.out.println(now);
        }
    }
  • 相关阅读:
    用两个栈实现队列
    重建二叉树
    从尾到头打印链表
    替换空格
    字符串比较
    二维数组的查找
    ORACLE---Unit01: 数据库原理 、 SQL(DDL、DML)
    [Python]小甲鱼Python视频第035课(图形用户界面入门:EasyGui)课后题及参考解答
    [Python]小甲鱼Python视频第032课(异常处理:你不可能总是对的)课后题及参考解答
    [Python]小甲鱼Python视频第030课(文件系统:介绍一个高大上的东西)课后题及参考解答
  • 原文地址:https://www.cnblogs.com/tszr/p/12370291.html
Copyright © 2011-2022 走看看