We write resource files
Password = Password format error font>
UserName = account format error font>
HBM.Session.Error = Establish an Hibernate Session error.
No.user = This is not found to have users.
HBM.Session.Query = Hibernate HQL query error.
Errors.Header = font color = red>
Errors.footer = ul> font>
Logon = landing
Logon.username = account number
Logon.password = password
Save to C: /1.txt
Then run
Native2ascii -Encoding GBK C: /1.TXT C: /ApplicationResources_zh_cn.properties
Will be generated C: /ApplicationResources_zh_cn.properties to copy to the src directory, we re-run this login program.
There is garbled, we forgot to set the JSP page encoding into UTF-8, add
ContentType = "text / html; charSet = UTF-8", refresh again
OK success
When you enter Chinese in the account box, it will appear in the picture.
There is a garbled, so that there is 3 cases:
1. Set Response to coding in each action, this method is more cumbersome, and each Action must be set once.
2. Use the filter in servlet2.3, unified settings
3. Overload the Process function in the ActionServlet.
The first method is difficult to obtain an encoding method through an XML configuration.
2, 3 can be solved by configuring parameters in Web.xml
This article describes how to use it, filter Filter
There is a ready-made coded filter under the Filter folder inside the Samples in Tomcat.
Copying, in Eclipse uses reconstruction, solve the Package mismatch problem.
The following is a web.xml for this filter.
Filter
->
init-param>
filter>
filter-mapping>
end
->
Start Tomcat test again, OK.