How to load i18n Property file using jQuery.i18n.properties.js + Spring 3 mvc

拟墨画扇 提交于 2019-12-12 23:23:28

问题


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

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>

回答1:


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




回答2:


try it

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

path:'resource/'


来源:https://stackoverflow.com/questions/17650773/how-to-load-i18n-property-file-using-jquery-i18n-properties-js-spring-3-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!