问题描述
<%@pagecontentType="text/html"pageEncoding="UTF-8"%><%@pageimport="java.sql.*"%><%@pageimport="javabean.User"%><html><head><metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"><title>登录处理页面</title></head><body><jsp:useBeanid="He"class="javabean.User"scope="page"></jsp:useBean><jsp:setPropertyproperty="*"name="He"/>if(He.lookforadmini()||He.lookfor()){//这行出现了错误!!!错误提示:这两个方法不可用response.sendRedirect("../writely/write.jsp");}else{response.sendRedirect("../login/login.jsp");}</body></html>下面是这两个方法的代码publicbooleanlookforadmini(Stringusername,Stringpassword){try{Heguangdb=newHeguang();Stringsql1="select*fromadministratorwhereusername='"+username+"'";ResultSetre=null;re=db.getexecuteQuery(sql1);if(re!=null){Stringsql2="select*fromadministratorwherepassword='"+password+"'";re=null;re=db.getexecuteQuery(sql2);if(re!=null){db.closeAll();re=null;returntrue;}else{db.closeAll();re=null;returnfalse;}}else{db.closeAll();re=null;returnfalse;}}catch(Exceptione){e.printStackTrace();returnfalse;}}publicbooleanlookfor(Stringusername,Stringpassword){try{Heguangdb=newHeguang();Stringsql1="select*fromuserwhereusername='"+username+"'";ResultSetre=null;re=db.getexecuteQuery(sql1);if(re!=null){Stringsql2="select*fromuserwherepassword='"+password+"'";re=null;re=db.getexecuteQuery(sql2);if(re!=null){db.closeAll();re=null;returntrue;}else{db.closeAll();re=null;returnfalse;}}else{db.closeAll();re=null;returnfalse;}}catch(Exceptione){e.printStackTrace();returnfalse;}}
解决方案
解决方案二:
<%if(He.lookforadmini()||He.lookfor()){response.sendRedirect("../writely/write.jsp");}else{response.sendRedirect("../login/login.jsp");}%>
解决方案三:
还是不行啊!!!
解决方案四:
publicbooleanlookforadmini改为publicstaticbooleanlookforadmini另外一个方法同样这样修改。
或者if(He.lookforadmini()||He.lookfor()){//这行出现了错误!!!错误提示:这两个方法不可用response.sendRedirect("../writely/write.jsp");}else{response.sendRedirect("../login/login.jsp");}改为Hehe=newHe();if(he.lookforadmini()||he.lookfor()){//这行出现了错误!!!错误提示:这两个方法不可用response.sendRedirect("../writely/write.jsp");}else{response.sendRedirect("../login/login.jsp");}
解决方案五:
这两个方法带有参数的哦:publicbooleanlookforadmini(Stringusername,Stringpassword){publicbooleanlookfor(Stringusername,Stringpassword){你在调用他们时,为什么没有参数?