Get the App
SLTechnology News&Howtos  ›  Development  › 

How to develop and solve the problem of Struts garbled code under Eclipse tool

Shulou Source: shulou.com Published: 2022-06-02 07:33:07 10月13日 Update

It is believed that many inexperienced people are at a loss about how to develop and solve the problem of Struts garbled under Eclipse tools. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

There are three main problems with Struts garbled:

1If value is in Chinese in the resource file in struts struts, struts garbled is displayed.

Solution: use the eclipse plug-in Properties Editor

2. Enter Chinese to display garbled codes in the text field.

Solution: use the servlet filter filter

In the simplest way, you can use the filters.SetCharacterEncodingFilter under tomcat to add tomcat to your web.xml configuration and servlet_examples the corresponding configuration (experts can configure it on their own!)

My configuration is as follows:

SetCharacterEncodingfilters.SetCharacterEncodingFilterencodingGBKSetCharacterEncoding*.do

3. Read out garbled codes from some databases.

Solution: re-encode the parts you want to display in Chinese

For example:

While (rs.next ()) {string col1=rs.getString (1); string col2=rs.getString (2); string col3=rs.getString (3); float col4=rs.getFloat (4); col1=new string (col1.getBytes ("iso-8859-1"), "GB2312"); col2=new string (col2.getBytes ("iso-8859-1"), "GB2312"); col3=new string (col3.getBytes ("iso-8859-1"), "GB2312"); -}

So far, the problem of Struts garbled has been solved.

After reading the above, have you mastered how to develop and solve the problem of Struts garbled under the Eclipse tool? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Garbled problems methods Chinese configuration tools development content methods more at a loss for this three Chinese reasons skills plug-ins data database Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi Huawei Microsoft MariaDB