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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring的国际化(转载)

發布時間:2025/3/15 javascript 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring的国际化(转载) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1:在MyEclipse下面創建一個test的Web? Project,然后添加Spring相關的文件,在src根目錄下創建applicationContext.xml文件。?

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans><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"/></beans>

2:在src根目錄下面創建4個資源文件:分別是?

messages_zh.properties main.title=你好 messages_en.properties main.title=Hello World! messages_ja.properties main.title=こんにちは messages_ko.properties main.title=??????

3:在WebRoot根目錄下面創建test.jsp?

<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib prefix="spring" uri="WEB-INF/lib/spring.tld"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Spring國際化</title></head><body><spring:message code="main.title" /><br><input type="button" value="<spring:message code="main.title" />"/><br></body> </html>

4:修改WEB-INF下面的web.xml

<context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:/applicationContext*,classpath*:META-INF/applicationContext*.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>

  這樣用Spring國際化的Test.jsp頁面就做好了:),此種方法是自動默認當前用戶的語言,比如客戶端是日語系統,就自動尋找messages_ja.properties資源文件,是英語系統,就自動尋找messages_en.properties資源文件。?


注意事項:?
1:用hibernate3.0,連接Mysql5.0數據庫。?

如果用hibernate.properties配置文件?
hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8?

如果用hibernate.cfg.xml配置文件?
jdbc:mysql://localhost:3306/test?useUnicode=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8?


2:頁面的編碼方式,應該選用utf-8?
<%@ page language="java"? pageEncoding="UTF-8"%>?


3:創建的數據庫的編碼方式也應該選用utf-8,以及表,字段的編碼方式都應選用utf-8?

注意以上3點就可以解決國際化時,所出現的頁面顯示亂碼問題,以及插入韓語時,出現的data too long for column問題.?

轉載于:https://www.cnblogs.com/toSeeMyDream/p/4106291.html

新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!

總結

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

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