问题描述
Theserverencounteredaninternalerror()thatpreventeditfromfulfillingthisrequest.exceptionorg.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:194inthegeneratedjavafileSyntaxerror,insert"elseStatement"tocompleteIfStatementAnerroroccurredatline:194inthegeneratedjavafileSyntaxerror,insert"}"tocompleteBlockAnerroroccurredatline:204inthegeneratedjavafileSyntaxerrorontoken"}",deletethistokenAnerroroccurredatline:205inthegeneratedjavafileSyntaxerror,insert"}"tocompleteClassBodyStacktrace:org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)下面为源码:***************1queryStudent.jsp************<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*,Bean.Student"errorPage="errorpage.jsp"%><%@pageimport="java.util.*;"%><%request.setCharacterEncoding("gb2312");Stringjudgement=request.getParameter("queryButton");ArrayListaList=null;Stringstu_id=null;if(judgement!=null){Studentstu=newStudent();stu_id=request.getParameter("stu_id");if(stu_id==null||stu_id.equals("")){%><scriptlanguage="javascript">alert('请输入要查询的学号!');</script><%}else{aList=stu.queryStudent(dep,stu_id);if(aList==null||aList.size()<=0){%><scriptlanguage="javascript"type="">alert('没有该学生信息!');</script><%}}}%><html><head><linkhref="Inc/student_com.css"type="text/css"rel="stylesheet"><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"></head><body><tablewidth="100%"border="0"><tr><palign="center"><fontcolor="#00FF00"size="+3"face="华文行楷">查询学生信息列表</font></p></tr><formname="form1"method="post"action=""><%if(aList!=null&aList.size()>0){Studentstu2=newStudent();for(inti=0;i<aList.size();i++){stu2=(Student)aList.get(i);%><tr><td>请输入要查询的学号:</td><td><inputname="stu_id"type="text"class="text1"value="<%=stu2.getId()%>"></td><td><inputname="queryButton"type="submit"value="查询"></td></tr><divalign="center"><tablecellpadding="2"cellspacing="1"><tr><tdalign="center"bgcolor="#EEEEEE">姓名</td><tdalign="center"bgcolor="#EEEEEE">密码</td><tdalign="center"bgcolor="#EEEEEE">年龄</td><tdalign="center"bgcolor="#EEEEEE">籍贯</td><tdalign="center"bgcolor="#EEEEEE">系别</td><tdalign="center"bgcolor="#EEEEEE">性别</td><tdalign="center"bgcolor="#EEEEEE">入学年份</td><tdalign="center"bgcolor="#EEEEEE">班级</td><tdalign="center"bgcolor="#EEEEEE">辅导员</td></tr><tr><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getName()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getPassword()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getAge()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getJiguan()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getDep()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getSex()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getEntry()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getClassid()%></td><tdalign="center"bgcolor="#FFFFFF"><%=stu2.getAssitant()%></td></tr>出现错误的地方——》<%}}%></table></div><palign="center"> </p><divalign="center"><ahref="javascript:history.back();">返回</a></div></form></table></body></html>***********************************2Student.java*************************************packageBean;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importSQL.SQLBean;publicclassStudent{privateStringid;privateStringpassword;privateStringname;privateStringsex;privateStringjiguan;privateStringclassid;privateStringdep;privateStringassitant;privateintage;privateintentry;}publicvoidsetAssitant(Strings){assitant=s;}publicStringgetAssitant(){returnassitant;}publicvoidsetClassid(Strings){classid=s;}publicStringgetClassid(){returnclassid;}publicvoidsetAge(intage){this.age=age;}publicintgetAge(){returnage;}publicvoidsetDep(Strings){dep=s;}publicStringgetDep(){returndep;}publicvoidsetSex(Strings){sex=s;}publicStringgetSex(){returnsex;}publicvoidsetEntry(intyear){entry=year;}publicintgetEntry(){returnentry;}publicStringgetId(){returnid;}publicvoidsetId(Stringid){this.id=id;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicStringgetPassword(){returnpassword;}publicvoidsetPassword(Stringpassword){this.password=password;}publicStringgetJiguan(){returnjiguan;}publicvoidsetJiguan(Stringjiguan){this.jiguan=jiguan;}publicArrayListqueryStudent(Stringdep,Stringstu_id){Stringsql="";ArrayListarrayList=newArrayList();if(dep.equals("0000")){sql="selectstudent.*,department.NAMEfromstudent,departmentwherestudent.DEPARTMENT=department.IDandstudent.id='"+stu_id+"'";}else{sql="selectstudent.*,department.NAMEfromstudent,departmentwherestudent.DEPARTMENT=department.IDandDEPARTMENT='"+dep+"'"+"andstudent.id='"+stu_id+"'";}SQLBeandb=newSQLBean();try{ResultSetrs=db.executeQuery(sql);intflag;while(rs.next()){Studentstu=newStudent();stu.setId(rs.getString(1));stu.setAge(rs.getInt(6));stu.setName(rs.getString(3));stu.setPassword(rs.getString(2));stu.setJiguan(rs.getString(7));stu.setDep(rs.getString(13));stu.setSex(rs.getString(4));stu.setClassid(rs.getString(8));entry=Integer.parseInt(rs.getString(5).substring(0,4));stu.setEntry(entry);stu.setAssitant(rs.getString(10));arrayList.add(stu);}returnarrayList;}catch(SQLExceptionex){ex.printStackTrace();returnnull;}finally{db.CloseDataBase();}}
解决方案
解决方案二:
aList!=null&aList.size()>0这个写错了吧。你写的是与运算了aList!=null&&aList.size()>0
解决方案三:
不是这个原因这个是我刚才重写时落下啦。