无尽之剑3 献祭地图:jsp调用包含中文的数据库的问题,求救

来源:百度文库 编辑:高校问答 时间:2024/04/28 03:59:10
String p = (String)request.getParameter("String_SQL");
if(p!=null)
String_SQL="select * from Users where name like '%"+p+"%'";
数据库中有中文,我想调出包含p的行,但是如果p是中文就出不来,怎么办呢?

//在最前面加上这条就可以解决中文问题了
request.setCharacterEncoding("gb2312");

//这里的(String)可以不写,request.getParameter返回的就是String
String p = (String)request.getParameter("String_SQL");

if(p!=null)
String_SQL="select * from Users where name like '%"+p+"%'";