java吧 关注:1,229,745贴子:12,691,740
  • 0回复贴,共1

求大神 jsp连接数据库查询不支持中文查询 utf-8 什么都改过

只看楼主收藏回复

大神们帮一下 很急 小弟才学一个星期 不太懂
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
<%@ page import="java.sql.*" %>
<jsp:useBean class="com.wgh.ConnDB" scope="page" id="conn"/>
<%
String inid=request.getParameter("inid");
String sql="SELECT * FROM yaopin WHERE shiyizheng="+inid+"";
System.out.print(sql);
ResultSet rs=conn.executeQuery(sql);//执行查询语句
int id=0;
%>
<head>
<title>药品查询</title>
<style>
.bodycenter
{display:block;
width:690px;
margin:0 auto;
padding-top:20px;
}
#username
{clear:both;
margin:0 auto;
width:690px;
text-align:right;
padding-top:10px;
}
#pic{
border:1px dotted;
height:600px;
width: 1300px;
}
</style>
</head>
<div id="pic">
<br><br><br>
<form name="form1" class="bodycenter" method="post" action="chaxun.jsp" ">
请输入症状:<input type="text" name="inid" size="25" value="">&nbsp;
<input type="submit" value="查询">&nbsp;&nbsp;&nbsp;
</form>
<table class="bodycenter" style="width:690px">
<th width="90px"><DIV align="center">药名</DIV></th>
<th width="90px"><DIV align="center">用量</DIV></th>
<th width="90px"><DIV align="center">适宜症</DIV></th>
<th width="90px"><DIV align="center">注意事项</DIV></th>
<th width="90px"><DIV align="center">备注</DIV></th>
<%
try{
if(rs.next()){
do{
id=rs.getInt(1);
%>
<tr style="padding:5px;">
<td align="center"><%=rs.getString(1)%></td>
<td align="center"><%=rs.getString(2)%></td>
<td align="center"><%=rs.getString(3)%></td>
<td align="center"><%=rs.getString(4)%></td>
<td align="center"><%=rs.getString(5)%></td>
</tr>
<%
}while(rs.next());
}else{
%>
<%
}
}catch(Exception e){
e.printStackTrace();
}
conn.close();//关闭数据库连接
%>
</table>
</div>


IP属地:浙江1楼2016-01-05 13:26回复