开发者社区> 问答> 正文

springmvc国际化问题

我配置了国际化

<!-- 国际化支持 -->
    <mvc:interceptors>
        <ref bean="localeChangeInterceptor" />
    </mvc:interceptors>
     
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="locale" />
    </bean>
    <bean id="localeResolver"  class="org.springframework.web.servlet.i18n.SessionLocaleResolver"></bean>  
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename">
            <value>messages</value>
        </property>
    </bean>

jsp部分代码:


访问方式1:
http://localhost:8080/testi18n/hello.do(访问直接返回jsp)
访问方式2:
http://localhost:8080/testi18n/index.jsp
方式1可以正常,但是方式2就报异常了
javax.servlet.jsp.JspTagException: No message found under code 'login.title' for locale 'zh'.

这是为什么呢?

展开
收起
a123456678 2016-03-16 14:13:14 2407 0
1 条回答
写回答
取消 提交回答
  • Using message bundles

    Internationalized messages are defined in message bundles accessed by a Spring MessageSource. To create a flow-specific message bundle, simply define messages.propertiesfile(s) in your flow's directory. Create a default messages.properties file and a .properties file for each additional Locale you need to support.
    
    #messages.properties
    checkinDate=Check in date must be a future date
    notHealthy={0} is bad for your health
    reservationConfirmation=We have processed your reservation - thank you and enjoy your stay
    From within a view or a flow, you may also access message resources using the resourceBundle EL variable:


    对照一下,你的方法是否满足spring mvc Internationalized messages

    2019-07-17 19:03:57
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载