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/>

  • 相关阅读:
    Codeforces Round #171 (Div. 2)
    ACdream 1079 郭式树
    HDOJ 1517 博弈论
    ACdream 1080 面面数
    博弈论 Nim 博弈
    Codeforces Round #172 (Div. 2)
    ACdream 1084 同心树
    STL bitset
    博弈论 bash博弈
    POJ 3261 后缀数组
  • 原文地址:https://www.cnblogs.com/limingxian537423/p/7282213.html
Copyright © 2011-2022 走看看