String a=request.getParameter("a");
String b=request.getParameter("b");
String c=request.getParameter("c");
String sql="select * from abc where 1=1 ";
if(!a.equals(""))
{
sql +=" and a='"+a+"'";
}
if(!b.equals(""))
{
sql +=" and b='"+b+"'";
}
if(!c.equals(""))
{
sql +=" and c='"+c+"'";
}
String b=request.getParameter("b");
String c=request.getParameter("c");
String sql="select * from abc where 1=1 ";
if(!a.equals(""))
{
sql +=" and a='"+a+"'";
}
if(!b.equals(""))
{
sql +=" and b='"+b+"'";
}
if(!c.equals(""))
{
sql +=" and c='"+c+"'";
}
解决方案 »
- web.xml启动servlet问题
- MyEclipse6.01启动tomcat时出错,提示:Multiple operations have reported errors.select a error to view its deta
- 请各位高手帮忙,一个简单的关于监听客户端的问题
- jsp的问题,为什么打印出来的是the value X is :null
- linux下jbuilder中文的解决问题
- servlet运行时需要servlet-api.jar文件吗?我的目录下删除了它,程序还可以运行。
- 怎样得到当前时间的小时数?
- 报表组件和打印组件
- jqPlot做折线,有对jqPlot熟练操作的么?求帮助!
- birt 集成web系统后,通过浏览器访问报表出现+ Unknown error!
- 如何使<html:link 映射成的相对地址,变成绝对地址
- 如何才能使网站中的XML文件不被外界读取??
sql=...
if(validate(a))sql+=...
if(validate(b))sql+=...
if(validate(c))sql+=...
if(a.equals("")&&a.equals("")&&a.equals(""))
OK!楼上的,五个星星以上是什么?
<!--function checkInput(myForm)
{
if(myForm.a.value==""&&myForm.b.value==""&&myForm.c.value=="")
{
alert("请输入查询内容");
myForm.a.focus();
return(false);
}}
//-->
</script><form action="" method="post" name="myForm" onSubmit="return checkInput(this)">
………………</form>
如果有合法的输入,查询的时候可以用楼上的方法!!
String b=request.getParameter("b");
String c=request.getParameter("c");
String sql="select * from abc where 1=1 ";
if(!a.equals(""))
{
sql +=" and a='"+a+"'";
}
if(!b.equals(""))
{
sql +=" and b='"+b+"'";
}
if(!c.equals(""))
{
sql +=" and c='"+c+"'";
}忘了说了,在a,b,c三项中,有组合查询的情况,比如:a b ,a c ,b c ,abc,组合查询。
所以上面的方法不是很合适。
<Script language="javascript">
<!--function checkInput(warehouse)
{
if((warehouse.warehouse_id.value=="") && (warehouse.bill_no.value=="") && (warehouse.item_no.value==""))
{
alert("请输入查询内容");
warehouse.warehouse_id.focus();
return(false);
}}
//-->
</script><form name="warehouse" method="post" action="" onSubmit="return checkInput(warehouse)">……</form>其中当if((warehouse.warehouse_id.value=="") && (warehouse.bill_no.value=="") && (warehouse.item_no.value==""))时,页面不起作用,
当为if(warehouse.warehouse_id.value=="")时,页面就可以起作用,难道javascript不能用“与”吗???还请高手帮忙,谢谢