问题描述
org.apache.jasper.JasperException:/logincheck.jsp(11,1)Expecting"jsp:param"standardactionwith"name"and"value"attributesorg.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)org.apache.jasper.compiler.Parser.parseParam(Parser.java:801)org.apache.jasper.compiler.Parser.parseBody(Parser.java:1646)org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:978)org.apache.jasper.compiler.Parser.parseForward(Parser.java:842)org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1094)org.apache.jasper.compiler.Parser.parseElements(Parser.java:1425)org.apache.jasper.compiler.Parser.parse(Parser.java:130)org.apache.jasper.compiler.ParserController.doParse(ParserController.java:238)org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)org.apache.jasper.compiler.Compiler.compile(Compiler.java:360)org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)javax.servlet.http.HttpServlet.service(HttpServlet.java:722)代码如下:<%@pagecontentType="text/html;charset=GBK"%><%@pageimport="login.LoginBean"%><jsp:useBeanid="user"class="login.LoginBean"scope="page"><jsp:setPropertyname="user"property="*"/></jsp:useBean><%if(user.checklogin()){Stringusername=request.getParameter("username");session.setAttribute("username",username);%><jsp:forwardpage="welcome.jsp"/><%}else{%><jsp:forwardpage="error.jsp"/><%}%>packagelogin;importjava.sql.*;publicclassLoginBean{privateStringusername;privateStringpassword;//privateStringposition;publicLoginBean(Stringusername,Stringpassword){//,Stringpositionthis.username=username;this.password=password;//this.position=position;}publicvoidsetUsername(String_username){this.username=_username;}publicStringgetUsername(){returnthis.username;}publicvoidsetPassword(String_password){this.password=_password;}publicStringgetPassword(){returnthis.password;}/*publicvoidsetPosition(String_position){this.position=_position;}publicStringgetPosition(){returnthis.position;}*/publicbooleanchecklogin(){booleanloginflag=false;Connectioncon=null;Statementstmt=null;ResultSetrs=null;try{Class.forName("com.mysql.jdbc.Driver");con=DriverManager.getConnection("jdbc:mysql://localhost:3306/logininformation?useUnicode=true&characterEncoding=GB2312","root","");stmt=con.createStatement();Stringsql="selectpersonalinformation.userID,personalinformation.password,positioninformation.positionfrompersonalinformation,positioninformationwherepersonalinformation.userID=positioninformation.userID";rs=stmt.executeQuery(sql);while(rs.next()){//System.out.println(rs.getString("userID"));//&&position.equals(rs.getString("positioninformation.position"))if(username.equals(rs.getString("personalinformation.userID"))&&password.equals(rs.getString("personalinformation.password"))){loginflag=true;//System.out.println(rs.getString("personalinformation.userID"));}/*else{System.out.println("false");}*/}}catch(Exceptione){System.out.print("getdataerror!");e.printStackTrace();}/*catch(Exceptionsqlex1){sqlex1.printStackTrace();}finally{if(con!=null){try{con.close();}catch(SQLExceptionsqlex2){sqlex2.printStackTrace();}}}*/returnloginflag;}}
解决方案
解决方案二:
飘过..看了一下不是太懂好象错误是JSP标准动作jsp:param..错误在:/logincheck.jsp页面中第11行附近..
解决方案三:
我知道问题出在哪里了。。。多了一个构造函数。。。。但是我把构造函数删掉也不行。。。不知道怎么回事完整代码:index.jsp<%@pagecontentType="text/html"%><%@pagepageEncoding="UTF-8"%><html><head><metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"><title>JSPlogin</title></head><body><h1>请登录系统</h1><formaction="logincheck.jsp"method="post">身份:<inputname="position"value="记者"/><br>用户:<inputname="username"value="A11111"/><br>密码:<inputname="password"type="password"value=""/><br><inputtype="submit"value="确认"/><inputtype="reset"/></form></body></html>welcome.jsp<%@pagecontentType="text/html;charset=GBK"%><html><head><title>welcome</title></head><bodybgcolor="#ffffff"><h1>登录成功</h1>欢迎您:<%out.println(session.getAttribute("username"));%><p></p><imgsrc="images/welcome.jpg"width="555"height="225"alt="welcome"/></body></html>error.jsp<%@pagecontentType="text/html;charset=GBK"%><html><head><title>error</title></head><bodybgcolor="#ffffff"><h1><imgsrc="images/error.jpg"width="191"height="199"alt="error"/>登录错误,请重试</h1><p></p><p></p><ahref="index.jsp">返回</a></body></html>logincheck.jsp<%@pagecontentType="text/html;charset=GBK"%><%@pageimport="login.LoginBean"%><jsp:useBeanid="user"class="login.LoginBean"scope="page"><jsp:setPropertyname="user"property="*"/></jsp:useBean><%if(user.checklogin()){Stringusername=request.getParameter("username");session.setAttribute("username",username);%><jsp:forwardpage="welcome.jsp"></jsp:forward><%}else{%><jsp:forwardpage="error.jsp"></jsp:forward><%}%>LoginBean.javapackagelogin;importjava.sql.*;publicclassLoginBean{privateStringusername;privateStringpassword;privateStringposition;publicvoidsetUsername(String_username){this.username=_username;}publicStringgetUsername(){returnthis.username;}publicvoidsetPassword(String_password){this.password=_password;}publicStringgetPassword(){returnthis.password;}publicvoidsetPosition(String_position){this.position=_position;}publicStringgetPosition(){returnthis.position;}publicbooleanchecklogin(){booleanloginflag=false;Connectioncon=null;Statementstmt=null;ResultSetrs=null;try{Class.forName("com.mysql.jdbc.Driver");con=DriverManager.getConnection("jdbc:mysql://localhost:3306/logininformation?useUnicode=true&characterEncoding=GB2312","root","");stmt=con.createStatement();Stringsql="selectp1.userID,p1.password,p2.positionfromlogininformationp1,positioninformationp2wherep1.userID=p2.userID";rs=stmt.executeQuery(sql);while(rs.next()){if(username.equals(rs.getString("p1.userID"))&&password.equals(rs.getString("p1.password"))&&position.equals(newString(rs.getString("p2.position").getBytes("iso8859-1"),"gb2312"))){loginflag=true;}}}catch(Exceptionsqlex1){sqlex1.printStackTrace();}finally{if(con!=null){try{con.close();}catch(SQLExceptionsqlex2){sqlex2.printStackTrace();}}}returnloginflag;}}报错:java.lang.ClassNotFoundException:com.mysql.jdbc.Driveratorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1664)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)atjava.lang.Class.forName0(NativeMethod)atjava.lang.Class.forName(UnknownSource)atlogin.LoginBean.checklogin(LoginBean.java:38)atorg.apache.jsp.logincheck_jsp._jspService(logincheck_jsp.java:71)atorg.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:73)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:722)atorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:378)atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:722)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:163)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:402)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:249)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)atorg.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)
解决方案四:
问题以解决:希望遇到类似问题的可以参考一下:1、、为导入mysql连接器:::在lib下2、set是就是乱码。。。导致以后转会都是错误的学要正确登录模块源码的朋友可以加我qq群:81893428