zoukankan      html  css  js  c++  java
  • JSTLView快速国际化(SpringMVC)

    JSTLView:快速国际化;只要导入了jstl的jar包,以前默认创建的InternalResouceView都会被使用jstlView替代;
       国际化的新步骤:
              1)、写好国际化资源文件 

        il118_en_US.properties
        il118_zh_CN.properties

              2)、在SpringMVC配置文件中配置管理国际化资源文件的消息管理器组件
    <!-- 注册一个国际化资源管理器;id必须是messageSource -->
        <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basename" value="i18n"></property>
        </bean>
       3)、去页面 使用fmt:message标签取值即可
     <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
        
    <form action="">
        <fmt:message key="prop.username"/><input type="text"/>
        <fmt:message key="prop.password"/><input type="text"/>
        <input type="submit"/>
    </form>

     注意事项:

    1)必须经过springmvc处理

    2)return不能是forword:或者redict:

    l  若希望直接响应通过 SpringMVC 渲染的页面,可以使用 mvc:view-controller 标签实现

    <!-- 直接配置响应的页面:无需经过控制器来执行结果 -->

    <mvc:view-controller path="/success" view-name="success"/>

    l  请求的路径:

    http://localhost:8080/SpringMVC_02_View/success

    l  配置<mvc:view-controller>会导致其他请求路径失效

    l  解决办法:

    <!-- 在实际开发过程中都需要配置mvc:annotation-driven标签,后面讲,这里先配置上 -->

    <mvc:annotation-driven/>

  • 相关阅读:

    logging 模块和日志
    re 模块和正则表达式
    collections 模块
    hashlib 模块
    序列化 json 和 pickle
    C++之以分隔符的形式获取字符串
    读取配置文件所在路径时的一种常见错误
    char和achar互转
    C++之ARX,Acstring,ACahr转char
  • 原文地址:https://www.cnblogs.com/limingxian537423/p/7282213.html
Copyright © 2011-2022 走看看