当前位置:web 服务器 > Tomcat >>

帮忙看一下 以下JSP代码错在哪 我在TOMCAT中运行 提示IF语句有异常

<%@page pageEncoding="gb2312"%> <% String username=request.getParameter("username"); String password=request.getParameter("password"); String certCode=request.getParameter("certCode"); int checked=123; if(!certCode.equals((String)session.getAttribute("certCode"))){ out.print("验证码错误!<br><br><a href=\"index.jsp\">返回登入界面</a>"); } else if(password.equals("123")&&username.equals("123")){ session.setAttribute("username",username); session.setAttribute("checked",checked); response.sendRedirect("youxi.jsp"); } else{ out.print("用户名或密码错误!<br><br><a href=\"index.jsp\">返回登入界面</a>"); } %>
追问:
        	
				
不清楚   把上面一个 IF去掉  tomcat中又提示下面一个if异常
答案:有什么异常啊  是不是certCode是null啊??
其他:if(!certCode.equals((String)session.getAttribute("certCode")))
你这里改成(!(certCode.equals((String)session.getAttribute("certCode"))))
试试,再不然把certCode换个变量名。尽量不要重复。 

上一个:JSP连接数据库的代码
下一个:求代码!!!!急! main.jsp实现当前用户显示,当前访问次数,实现退出,显示当前时间。 跪求高手解决!

Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,