Handling Chinese methods in JSP!

zhaozj2021-02-16  55

Description: The environment I use is: resin3.0 mysql5.0 Eclipse Struts

1. First, you must guarantee the following line of code on the submitted page:

ContentType = "text / html; charset = GB2312"

2. There must be the following before saving the data submitted:

Request.setCharacterencoding ("GB2312"); // This line must be placed in front of Request.GetParameter ("XX")

Convert the obtained data.

String name = new string (Request.GetParameter ("name"). GetBytes ("ISO8859_1"), "GB2312");

3. When linking MySQL, it is necessary to add a parameter:

"JDBC: mysql: // localhost: 3306 / test? useunicode = true & characterencoding = GB2312"

4. Convert it when reading data from the database:

<% out.println (new string (dzbjbqk.getdzb_name (). getBytes ("ISO8859_1")))));%>

These four points are guaranteed, there should be no problem, I am also only knowing the table! ! ! ! ! !

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

New Post(0)