Struts International Problem Solution

xiaoxiao2021-03-06  15

1. Resolve Chinese issues in the JSP page: Plus <% @ Page ContentType = "text / html; charset = GBK" in each JSP header: HTML: html locale = "true"> means using local coding.

2. Solve Chinese issues in the resource package To call the information in the resource package, we need this information in Chinese, but the resource package cannot be written directly in Chinese. Otherwise there will be garbled.

Steps: 1) First write the information of the resource package into the Chinese information you need, save the applicationResources_zh.properties 2 Run the CMD to the resource package where you are located, run the JDK command: native2ascii -Encoding GB2312 ApplicationResources_ZH.Properties Temp.txt will be Encoding is converted to ASCII, stored in TEMP.TXT. Copy the contents in Temp.txt and use it override the original content of ApplicationResources_ZH.Properties. 3) Do not need to change the resource package settings in Struts-Config.xml, which will determine according to the settings of the browser, select the corresponding resource package. For example, in IE Tool -InetNet Options - Language, select the language you need. You can choose a variety of languages, but the system will select the resource package based on the relationship. If Chinese is placed in front, the system will use the resource package of ApplicationResources_zh.Properties. 3. Solve the Chinese problem in page data transfer JSP to the bean, and then pass it to the JSP by bean, and it is garbled when the page is displayed. Add the font class in Web.xml, the content is as follows: set character encoding filters.setCharacterencodingfilter Encoding GBK Set Character Encoding *. do Here you can find a font class, setcharacterencodingfilter, can be found in JSP-Examples, or Refer to the example. You can copy the Filters file there to your class below. Here you need to pay attention to the content of , and write it here into action in many web pages. But if you write, you can't find the project. So, I write it into * .do. If it is simple JavaBean, you can write / *.

4. Solution of GET (Struts does not need this setting, just with instructions) Open Tomcat's server.xml file, find blocks, add the following line: uriencoding = "GBK" is complete as follows:

转载请注明原文地址:https://www.9cbs.com/read-46620.html

New Post(0)