日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

springmvc国际化

發布時間:2025/1/21 c/c++ 96 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springmvc国际化 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

1、配置

?在spring配置文件中引入國際化

<!-- 定義國際化消息 --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="messages"/> </bean> <!-- 獲取本地 --> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"/> <mvc:interceptors> <!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de --> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" /> </mvc:interceptors>

2、建立兩個文件messages_en.properties 和 messages_zh.properties,分別對應英文和中文

需注意中文配置文件

3、在jsp頁面中的使用

引入spring標簽

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> 使用標簽進行國際化 <spring:message code="parentId"/>//parentId為配置文件中的key值 4、在java類里面的使用方式

?先獲取HttpServletRequest request對象

RequestContext requestContext = new RequestContext(request);//獲取請求上下文對象Locale myLocale = requestContext.getLocale();//獲取locale對象System.out.println(myLocale);//得到國際化名稱zh_CN en_USSystem.out.println(requestContext.getMessage("name"));//通過key獲取國際化文件中的value

?

轉載于:https://my.oschina.net/u/615618/blog/161638

總結

以上是生活随笔為你收集整理的springmvc国际化的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。