There are some steps to use Spring label library.
1、down load library:spring-form.tld,spring.tld.you can down these files from Spring official page:http://www.springsource.org/download,then put them under the direction of /WEB-INF.
2、Configure lable lib
Write following configure into web.xml file bewteen element of <web-app> and </web-app>:
<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/spring.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/spring-form</taglib-uri>
<taglib-location>/WEB-INF/spring-form.tld</taglib-location>
</taglib>
</jsp-config>
3、configure Spring resource lib
write following context into applicationContext.xml file.
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>com.demo.spring.resources.ApplicationResources</value>
</property>
</bean>
u should pls pay attention to the value element .eg :com.demo.spring.resources.ApplicationResources,all your properties will be created under com.demo.spring.resources,and your properties will named begin as ApplicationResources,if you don't do as this rule ,IDE will show error message:No message found under code 'register.page.title' for locale 'zh_CN' when you run your project.
4、configure resource files
u can create ApplicationResources.properties,ApplicationResources_zh_CN.properties,ApplicationResources_en.properties under page com.demo.spring.resources.
eg.ApplicationResources.properties file content:
#login.jsp
login.page.title=Login Window
login.page.username=Username
login.page.password=Password
login.page.login=Login
login.page.register=Register
#register.jsp
register.page.title=Register Window
register.page.username=Username
register.page.password1=Password
register.page.password2=Confirm Password
register.page.email=Email
register.page.register=Register
register.page.back=Back
#welcome.jsp
welcome.page.title=Login is successful!
welcome.page.username=Welcome,
welcome.page.logout=Logout
Resource file's name have a format:"default resource file name"+"_country"+"_language.properties",default resource file name is the value u defined in applicationContext.xml ,such as ths eg we defined is ApplicationResources
5、label words in u jsp page
eg.login.jsp
firstly ,add <%@taglib prefix="spring" uri="/spring" %> into your jsp page,be careful,/spring is the direction u defined in web.xml as step 1.
secondly,add label for jsp.as blowing:
<form name="form1" action="login.do" method="POST">
<table border="1" width="200">
<tr>
<td colspan="2"><spring:message code="login.page.title" /></td>
</tr>
<tr>
<td><spring:message code="login.page.username" /></td>
<td><input type="text" name="username" size="10"></td>
</tr>
<tr>
<td><spring:message code="login.page.password" /></td>
<td><input type="password" name="password" size="10"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value='<spring:message code="login.page.login" />'>
<a href="register.do?method=init"><spring:message code="login.page.register" /></a>
</td>
</tr>
</table>
In this eg,i use <spring:message>label.There are also three labels:<spring:hasBindErrors>,<spring:bind>,<spring:transform> in lable library.
Reference:《开发者突击:java web主流框架整合开发 j2ee+Structs+Hibernate+Spring》 刘中兵编著 ,电子工业出版社

