Application_TMP.Properties
Word.key = wordhello.key = Hello aaaa.key = This bean exists. Bbbb.key = This bean does not exist. Error.key = An error occurred, please check! Params.key = Dark secret, {0}, no? 徊 徊 徊 {{1}, I will me, I me, I, {2},
Code conversion command:
D: / yangjin / test3> native2ascii -encoding gbk ./web-inf/classes/test/application_cn_tmp.properties ./web-inf/classes/test/application_zh_cn.properties
Application_zh_cn.properties
Word.key = WordHello.key = / u4f60 / u597daaaa.key = / u8fd9 / u4E2abean / u5b58 / u5728.bbbbb.key = / u8fd9 / u4E2abean / u4E0D / u5B58 / u5728.Error.Key = / u53d1 / u751f / u4E00 / U4E2A / U9519 / U8BEF / UFF0C / U8BF7 / U68C0 / U67E5 / UFF01PARAMS.KEY = / U6697 / U6697 / U6697 / U6697 / U6697 / U6697 / U554A, {0}, / U4E0D / U4E0D / U4E0D / U4E0D / U4E0D / U4E0D / U4E0D / U4E0D, {1}, / U6211 / U6211 / U6211 / U6211 / U6211 / U6211 / U6211, {2}, / U7684 / U7684 / U7684 / U7684 / U7684 / U7684 / U7684
Application.properties
Word.key = WordHello.key = helloaaa.key = this bean is present.bbbb.key = this bean isn't present.error.key = rarams.key = aaaaaaaaaa, {0}, bbbbbbbbbbbb , {1}, cccccccccc, {2}, dddddddddd
Application_en.properties // Plus "_" after the string, so as to distinguish between the default file.
word.key = word_hello.key = hello_aaaa.key = this bean is present._bbbb.key = this bean is not present._error.key = raise a error, please check! _params.key = AAAAAAAAAAA, {0}, BBBBBBBBBB , {1}, cccccccccc, {2}, dddddddddd_
Hellobean.java
.......
Private Boolean Match (String Str) {Pattern P = Pattern.Compile ("[^ 0-9] "); // Regular Expression Verification: If the string contains numbers, return errors. Matcher m = p.matcher (str); return m.matches ();} public ActionErrors validate (ActionMapping mapping, HttpServletRequest request) {ActionErrors errors = new ActionErrors ();! If (word == null || match (word) ) {ErrorS.Add ("Word", New ActionMessage ("Error.Key");} Return Errors;} struts-config.xml
XML Version = "1.0" encoding = "UTF-8"?>
Error.jsp
<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% @ Taglib Uri = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%>
result:
Set the "Language" option of the browser to "En".
Http: // localhost: 2000 / test3 / helloaction.do? word = bi234
Raise a Error, please check! _
Set the "Language" option of the browser to "zh_cn". Http: // localhost: 2000 / test3 / helloaction.do? word = bi234
An error occurred, please check!