在JSP中输入中文查询条件,查询后无记录,后台读出SQL显示,是乱码!
select M.USERID as USERID,M.USERNAME as USERNAME,M.MOBILEPHONE as MOBILEPHONE from CHNUSERUSERTEST M where M.USERNAME = '??' and 1 = 1
不知道是怎么回事,希望有人指点,谢谢。
select M.USERID as USERID,M.USERNAME as USERNAME,M.MOBILEPHONE as MOBILEPHONE from CHNUSERUSERTEST M where M.USERNAME = '??' and 1 = 1
不知道是怎么回事,希望有人指点,谢谢。
response.setContentType("text/html");
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
但是注意代码的编码最好和数据库的编码要一致!
个人比较推荐都是用utf-8
或者request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("gbk");
utf-8那是你使用的字符串, 也可能是gbk 看你项目而定 或者干脆new String (request.getParameter(“paraName”).getBytes(“iso9959-1”))
request.setCharacterEncoding("GBK") ;
%>
在body下
jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
或者数据库设置字符集 mysql set names gbk;
这中方式是发送与请求字节码的set(设置),GBK可以,最好是用utf-8
<%
String username=request.getParameter("suid");
username = new String(username.getBytes("iso-8859-1"),"utf-8");//将用户名转码%>后台
java.net.URLDecoder.decode(username , "UTF-8"); //解码!
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" />
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" />