jsp mysql 中文乱码问题
从JSP存储到MYSQL里,中文在数据库里显示正常
用编号从JSP页面查询,读取中文也正常显示,
但用中文输入JSP页面查询,就显示不出来了,请大家帮忙看看,
谢谢!!!
代码:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="cim.*" %>
<%@ include file="sessionadmin.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<title>档案系统</title>
<SCRIPT language=javascript>
function Chk(theForm)
{
if (theForm.no.value == ""){
alert("请输入姓名!");
theForm.no.focus();
return (false);
}
}
</SCRIPT>
<link rel="stylesheet" href="images/css.css" type="text/css" media="screen">
</head>
<BODY text="#000000" topmargin=0>
<DIV id=overDiv style="Z-INDEX: 1; POSITION: absolute"></DIV>
<TABLE cellSpacing=1 cellPadding=0 width="98%" align=center border=0 class="tableBorder">
<TBODY>
<TR>
<FORM name="Form1" action="staff_search.jsp" method="post" onSubmit="return Chk(this);">
<th align=middle colSpan=6 height=22 bgcolor="#CCCCCC">
<input type="text" name="name" size="15" maxlength="15""/>
<input type="SUBMIT" name="Submit" value="SSS" />
</th>
</FORM>
</TR>
</TABLE>
</FORM>
<table width="200%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td width="9%" height="20" class=forumrow>查询结果</td>
</tr>
</table>
<TABLE cellSpacing=1 cellPadding=0 width="200%" align=center border=0 class="tableBorder">
<TBODY>
<TR>
<th width="60" height="20">员工号</th>
<th width="70" height="20">姓名</th>
<th width="100" height="20">拼音</th>
<th width="30" height="20">性别</th>
</tr>
<%
request.setCharacterEncoding("GB2312");
String no=request.getParameter("name");
DBConnect dbc = new DBConnect();
if(no!=null){
String sql="select no,name,spell,sex from staff_base where name = '"+name+"'";
ResultSet rs = dbc.executeQuery(sql);
try{
while(rs.next()){
%>
<tr>
<td align="CENTER" bgcolor="#F3F3F3"><%=rs.getString("no") %></td>
<td align="CENTER" bgcolor="#F3F3F3"><%=rs.getString("name") %></td>
<td align="CENTER" bgcolor="#F3F3F3"><%=rs.getString("spell") %></td>
<td align="CENTER" bgcolor="#F3F3F3"><%=rs.getString("sex") %></td>
</tr>
<%
}
}catch(Exception e){
System.err.println(e);
dbc.close();
}finally{
}
}
%>
</table>
</BODY>
</HTML>