怎么根据输入框的字符进行查询啊?代码如下:

chendi0301 2006-05-07 12:31:51
search.jsp
<form name="form1" action="search_result.jsp">
...
<tr>
<td><div align="center">输入学号:</div></td>
<td><input name="stu_num" type="text" size="12"></td>
</tr>
...

search_result.jsp
<%
String stu_id=request.getParameter("stu_num").toString();
out.print(stu_id);//这里能够获得值
String sql="select * from student where stu_id='"+stu_id+"'";//这里的SQL查询语句该怎么写啊?
ResultSet rs = stmt.executeQuery(sql);

%>

...全文
78 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeason1914 2006-05-07
  • 打赏
  • 举报
回复
语法没错

不过最好用like 之前最好检验一下传来的字符串

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧