MyEclipse中jsp页面的if和else语句
这是一个登录页面,部分代码如上
a=rs.next();
if(a==true)
{
//用户id及密码输入正确的情况
rs.close();
session.setAttribute("uid", uid);
%>恭喜登录成功<%}
else
{
rs.close();
%>
<p> </p>
<p>对不起,您的输入有误,请重新填写!</p>
<p><input type="button" name="Button2" value="返回上一步"
onclick="backward()" /></p>
<%}%>
这里的语句有什么问题,为什么不管输入什么总是同时执行if和else语句呢?
追问:不对呀,你没看清楚
答案:a=rs.next();
if(a==true)
{
//用户id及密码输入正确的情况
rs.close();
session.setAttribute("uid", uid);
}%>恭喜登录成功<%
else
{
rs.close();
<%}%>
<p> </p>
<p>对不起,您的输入有误,请重新填写!</p>
<p><input type="button" name="Button2" value="返回上一步"
onclick="backward()" /></p>
其他:区域不匹配,检查{}的范围
上一个:数据库里的时间,传到JSP页面,怎么再转回成时间格式
下一个:jsp中 怎样实现如果用户不点击同意注册协议,则不能点击注册按钮