Solution to garbled code after jsp inserts mysql database

Source: Internet
Author: User

The following three statements are used on the jsp (preferred for SUN Enterprise Applications) page to ensure gbk encoding.
<% @ Page session = "true" %>
<% @ Page contentType = "text/html; charset = gbk" %>
<% @ Page pageEncoding = "gbk" %>
<% Request. setCharacterEncoding ("gbk"); %>

 


Use the following statement to connect to a database:
String sConnStr = "jdbc: MySQL (the best combination with PHP): // localhost: 3306/test? User = michael & password = 123456 & useUnicode = true & characterEncoding = gbk ";
In addition, the content of my. ini in MySQL (the best combination with PHP) is as follows:
Basedir = D:/MySQL (the best combination with PHP)
# Bind-address = 127.0.0.1
Datadir = D:/MySQL (the best combination with PHP)-data/data
Default_character_set = gbk
# Language = D:/MySQL (the best combination with PHP)/share/your language directory
# Slow query log # =
# Tmpdir # =
# Port = 3306
# Set-variable = key_buffer = 16 M
[WinMySQL (best combination with PHP) admin]
Server = D:/MySQL (the best combination with PHP)/bin/mysql(and php ))))))))d-nt.exe
User = michael
Password = 123
[Client]
Default_character_set = gbk

The parameters passed between read jsp (preferred for SUN Enterprise Applications) pages are displayed normally on the page
After data is inserted under the doscommand line, the display is normal.

One of the insert statements is as follows:
<Jsp (preferred for SUN Enterprise Applications): useBean id = "reg" scope = "page" class = "test. chatreg"/>
String strSQL = "insert into chatreg (username, password, email, homepage)
Values ("+ regName +", "+ regPassword +", "+ regEmail +", "+ regHomepage + ")";
Reg.exe cuteQuery (strSQL );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.