<=,>=这些在jsp页面中总是被看成是<=的等值,该怎么样写啊??
求救!以下是我的部分代码:
大家看一下我的Condi这样写错在哪里??String Condi="score <="+xuefenmax+"AND"+"score>="+xuefenmin;
String condition="SELECT * FROM student where"+Condi;
out.println(Condi+", "+condition); // 输出出错!!!
try{
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(condition);
求救!以下是我的部分代码:
大家看一下我的Condi这样写错在哪里??String Condi="score <="+xuefenmax+"AND"+"score>="+xuefenmin;
String condition="SELECT * FROM student where"+Condi;
out.println(Condi+", "+condition); // 输出出错!!!
try{
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(condition);
解决方案 »
- 一个cookie问题
- HttpClient中的getResponseBodyAsString没有反应!!高手来
- 域名访问遇到Bad Request,求高手帮忙,现金酬谢
- 在java文件中启动tomcat6出现java.lang.NoClassDefFoundError
- 请教: jsp 刷新后重复提交数据
- Tomcat 启动报错查不出原因
- 一个工程里,javabean写main函数测试可以连接oracle数据库,可是从jsp调用servlet,servlet继续调用javabean类时,java.sql抛出错误:No
- 不回答我,我跳楼!!!!jsp用什么做WEB服务器好,网站日访问量达一万多,
- 怎样用参数设置另一窗口的text的值?
- 关于图片上传的例子??
- 请教大家个问题,如何获得别的网站里的内容?
- 问个小问题,请高手解答!在线等!
String Condi="score <="+xuefenmax+"AND score >="+xuefenmin;
out.println(Condi+", "+condition); // 输出出错!!!
出的错误具体是什么?
<%@ include file="connection.jsp" %>
<html>
<head>
<title>
xuefen
</title>
</head>
<body bgcolor="#ffffff">
<%//获取提交的学分的最大值和最小值:
String xuefenmax=request.getParameter("xuefenmax");
if(xuefenmax==null){
xuefenmax="100";
}
String xuefenmin=request.getParameter("xuefenmin");
if(xuefenmin==null){
xuefenmin="0";
}
String Condi="score <="+xuefenmax+"AND"+"score>="+xuefenmin;
String condition="SELECT * FROM student where"+Condi;
out.println(Condi+", "+condition);
try{
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(condition);
%>
<center>
输出<%=Condi%>的学生信息:<br />
<table border="" bgcolor="#74bbc0">
<tbody>
<tr>
<td width="100">学号</td>
<td width="100">姓名</td>
<td width="50">学分</td>
</tr>
<%while(rs.next()){ %>
<tr align="center">
<td><%=rs.getString(1) %></td>
<td><%=rs.getString(2) %></td>
<td ><%=rs.getInt(3) %></td>
</tr>
<%} %>
</tbody>
</table>
</center>
<%
conn.close();
}
catch(SQLException e1){e1.printStackTrace(); out.print("读取数据出错!!");}
%>
<br />
<hr />
<a href="chap3-4.jsp">返回</a>
</body>
</html>
String condition="SELECT * FROM student where"+Condi;注意字符串之间的空格String Condi="score <= "+xuefenmax+" AND score >= "+xuefenmin;
String condition="SELECT * FROM student where "+Condi;
经过上面的这个String Condi="score <="+xuefenmax+"AND"+"score>="+xuefenmin;
你的Condi就是你的SQL的where条件了!
好久没来了,看看id还能用不!
String condition="SELECT * FROM student where"+Condi;
在上面两句话之后加上下面两句:
out.println("Condi"=Condi);
out.println("condition"=condition);
然后在控制台看看是不是正确地!
out.println("Condi="+Condi);
out.println("condition="+condition);
在jbuilder中显示错误,但是IE中显示正确,很是奇怪