如何使用jQuery.i18n.properties.js +弹簧3 MVC加载国际化属性文件(Ho

2019-10-18 08:58发布

我曾在春季3 mvc.I配置本地化和内在放在属性文件中的资源folder.And其工作properly.Now我想使用JavaScript内根据语言提供适当的警报消息。 下面的属性文件我的项目结构,给出

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

我想使用jQuery internalization.Now我要访问使用jQuery.I这些属性文件在JavaScript中写下面的代码加载我的属性文件

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>

Answer 1:

你在你的项目结构列表中的路径是resource ,而不是resources 。 希望你周围的错误了。



Answer 2:

试试吧

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

path:'resource/'


文章来源: How to load i18n Property file using jQuery.i18n.properties.js + Spring 3 mvc