如何使用jQuery.i18n.properties.js + Spring 3 MVC加载i18n属性文件 [英] How to load i18n Property file using jQuery.i18n.properties.js + Spring 3 mvc

查看:97
本文介绍了如何使用jQuery.i18n.properties.js + Spring 3 MVC加载i18n属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Spring 3 mvc中配置了Localization and Internalization.我将属性文件放在资源文件夹中,并且它可以正常工作.现在我想使用Javascript内部化来根据语言提供适当的警报消息. 下面是属性文件的我的项目结构"

I have configured Localization and Internalization in Spring 3 mvc.I put properties files in resource folder.And Its working properly.Now I want to use Javascript internalization to provide proper alert messages according to the languages. My Project Structure is given below for properties files

Project
|
|
src
resource
|_message.properties
|_message_en.properties
|_message_es.properties

我想使用jQuery内部化.现在我想使用jQuery访问这些属性文件.我已经在javascript中编写了以下代码以加载我的属性文件

I want to use jQuery internalization.Now I want to access these properties files using jQuery.I have written below code in javascript to load my properties file

jQuery.i18n.properties({
    name:'message', 
    path:'resources/', 
    mode:'both',
    language:'en'
});

**But I am getting Http 404 Error during loading of the page.**

**GET http://SERVER IP:PORT/viuw/resources/message.properties?_=1373877147985 404 (Not Found)** 

How to load Property files using jQuery.i18n.property.js?

my configuration is
  <bean id="localeResolver"
        class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
        <property name="defaultLocale" value="es" />
    </bean>

    <bean id="localeChangeInterceptor"
        class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="language" />
    </bean>
    <bean
        class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
        <property name="interceptors">
            <list>
                <ref bean="localeChangeInterceptor" />
            </list>
        </property>
    </bean>
    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="message" />
    </bean>


web.xml file configuration is


   <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
    <url-pattern>/</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>

推荐答案

您在项目结构中列出的路径是resource,而不是resources.希望您能解决该错误.

The path you list in your project structure is resource, not resources. Hope you got around that error.

这篇关于如何使用jQuery.i18n.properties.js + Spring 3 MVC加载i18n属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆