Jsp connection SqlServer Chinese garbled problem

Jsp connection SqlServer Chinese garbled problem

	初学jsp与SqlServer连接,在完成一系列的连接数据库操作后,成功的存入数据
结果在输入中文时出现了乱码(如下图所示)

insert image description here
The following is the process I solved:
1. First, add charset=gb2312 at the beginning of jsp
2. Set the type in the database to nvarchar
(Reference: https://blog.csdn.net/u012575083/article/details/13769111?utm_medium=distribute. pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase&depth_1-utm_source=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecas)
3. When transferring data between jsp files:

String name1=new String(request.getParameter("name").getBytes("iso8859_1"),"gbk");
request.setCharacterEncoding("gb2312");

This realizes saving in Chinese format when reading

The final result is as follows:
insert image description here

Guess you like

Origin blog.csdn.net/ws15168689087/article/details/111050290
Recommended