日期:2014-05-18  浏览次数:20846 次

奇怪问题求解!
<%
String   bookID   =   request.getParameter( "add ");
// if(bookID!=null)
BookInfo   book1   =   DB.getBookInfo(bookID);
out.println(bookID);
%>
这段代码没问题,但是如果我不注释掉if语句,就会出现

org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP:  

An   error   occurred   at   line:   9   in   the   jsp   file:   /index.jsp
Syntax   error,   insert   "AssignmentOperator   ArrayInitializer "   to   complete   ArrayInitializerAssignement
6:   <%
7:   String   bookID   =   request.getParameter( "add ");
8:   if(bookID!=null)
9:   BookInfo   book1   =   DB.getBookInfo(bookID);
10:   out.println(bookID);
11:   %>
12:  


An   error   occurred   at   line:   9   in   the   jsp   file:   /index.jsp
Syntax   error,   insert   "; "   to   complete   Statement
6:   <%
7:   String   bookID   =   request.getParameter( "add ");
8:   if(bookID!=null)
9:   BookInfo   book1   =   DB.getBookInfo(bookID);
10:   out.println(bookID);
11:   %>
12:  

我感觉好像BookInfo   book1   =   DB.getBookInfo(bookID);不能放在if条件中。



------解决方案--------------------
<%
String bookID = request.getParameter( "add ");
BookInfo book1 = null;
if(bookID!=null){
book1 = DB.getBookInfo(bookID);
}
out.println(bookID);
%>
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.aiyiweb.com/j2ee/2308.html