锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
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鏍圭洰褰曚笅闈㈠垱寤?涓祫婧愭枃浠訛細鍒嗗埆鏄?br />
messages_zh.properties
main.title=浣犲ソ
messages_en.properties
main.title=Hello World!
messages_ja.properties
main.title=銇撱倱銇仭銇?br />
messages_ko.properties
main.title=鞎堧厱頃橃嫮雼堦箤
3錛氬湪WebRoot鏍圭洰褰曚笅闈㈠垱寤簍est.jsp
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鍥介檯鍖?lt;/title>
聽聽</head>
聽 <body>
聽
聽聽聽 <spring:message code="main.title" /><br>
聽聽聽 <input type="button" value="<spring:message code="main.title" />"/><br>
聽聽</body>
</html>
4:淇敼WEB-INF涓嬮潰鐨剋eb.xml
鍦╳eb.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>
榪欐牱鐢⊿pring鍥介檯鍖栫殑Test.jsp欏甸潰灝卞仛濂戒簡:),姝ょ鏂規硶鏄嚜鍔ㄩ粯璁ゅ綋鍓嶇敤鎴風殑璇█錛屾瘮濡傚鎴風鏄棩璇郴緇燂紝灝辮嚜鍔ㄥ鎵?font size="3">messages_ja.properties璧勬簮鏂囦歡錛屾槸鑻辮緋葷粺錛屽氨鑷姩瀵繪壘messages_en.properties璧勬簮鏂囦歡銆?/font>
娉ㄦ剰浜嬮」:
1:鐢╤ibernate3.0,榪炴帴Mysql5.0鏁版嵁搴撱?br />
聽濡傛灉鐢╤ibernate.properties閰嶇疆鏂囦歡
聽hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
濡傛灉鐢╤ibernate.cfg.xml閰嶇疆鏂囦歡
jdbc:mysql://localhost:3306/test?useUnicode=true&useUnicode=true&characterEncoding=utf-8&mysqlEncoding=utf8
2:欏甸潰鐨勭紪鐮佹柟寮忥紝搴旇閫夌敤utf-8
<%@ page language="java"聽 pageEncoding="UTF-8"%>
3:鍒涘緩鐨勬暟鎹簱鐨勭紪鐮佹柟寮忎篃搴旇閫夌敤utf-8錛屼互鍙婅〃錛屽瓧孌電殑緙栫爜鏂瑰紡閮藉簲閫夌敤utf-8
娉ㄦ剰浠ヤ笂3鐐瑰氨鍙互瑙e喅鍥介檯鍖栨椂錛屾墍鍑虹幇鐨勯〉闈㈡樉紺轟貢鐮侀棶棰橈紝浠ュ強鎻掑叆闊╄鏃訛紝鍑虹幇鐨刣ata too long for column闂.