关于写基于mvc网上商店时出现的问题?
在编写时出现下面的问题org.apache.jasper.JasperException: An exception occurred processing JSP page /searchview.jsp at line 59
56:session.setAttribute("namenull",null);
57:
58: }
59: else if(((Vector)session.getAttribute("result")).isEmpty()){
60: out.println("<h3>there is no content that you query</h3>");
61:
62: }
root cause
java.lang.NullPointerException
org.apache.jsp.searchview_jsp._jspService(searchview_jsp.java:124)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
以下是上面问题出现的源码:
<%--
Document : searchview
Created on : 2011-11-4, 14:23:26
Author : huyujin
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import= "java.sql.*,java.util.*" %>
<%@page import= "org.netbeans.web.*"%>
<%!
int pageRecordNum=5;
int pageCount;
%>
<%
String tempPageNum=request.getParameter("pageno");
try{
if(tempPageNum==null){
pageCount=1;
}
else
{
pageCount=Integer.parseInt(tempPageNum);
}
}catch(Exception e){
e.printStackTrace();
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name="search" action="CustomerServlet" method="post">
query the name of goods:
<input type="text" name="productName" vlaue="" width="40" />
<select name="searchType" >
<option value="jingque">精确查找</option>
<option value="mohu">模糊查找</option>
</select>
<input type="hidden" vlaue="select" name="action">
<input type="submit" value="query" />
<a href="CustomerServlet?action=getall">查看所有商品</a>
</form>
<form action="CustomerServlet" method="post" name="result">
<input type="hidden" name="pageno" value="<%=pageCount%>" />
<%
if(session.getAttribute("namenull")!=null){
out.println("<h3>please input the name of goods!</h3>");
session.setAttribute("namenull",null);
}
else if(((Vector)session.getAttribute("result")).isEmpty()){
out.println("<h3>there is no content that you query</h3>");
}
else{
%>
<table align="center" width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td> select goods</td>
<td> product_id</td>
<td> product_name</td>
<td> product_price</td>
<td> product_num</td>
<td> product_describe</td>
</tr>
<%
Vector vec=(Vector)session.getAttribute("result");
int size=vec.size();
for(int i=(pageCount-1)*5;i<(pageCount-1)*5+pageRecordNum;i++){
ProductBean tempbean=(ProductBean)vec.elementAt(i);
int productId=tempbean.getProduct_id(); //获取ID的属性值
%>
<tr>
<td> <input type="checkbox" name="choose" value= "<%= tempbean.getProduct_id() %>" /></td>
<td> <%= tempbean.getProduct_id() %> </td>
<td><%= tempbean.getProduct_name() %> </td>
<td> <%= tempbean.getProduct_price() %> </td>
<td> <%=tempbean.getProduct_num() %> </td>
<td> <%=tempbean.getProduct_describe() %> </td>
</tr>
<%
if(i>=size-1)
break;
}
%>
</table>
<%
if(pageCount!=1){
%>
<a href="CustomerServlet?action=previous&pageno=<%=pageCount-1%>"> 上一页</a>
<%
}
int lastPageNum=size/pageRecordNum;
if(size%pageRecordNum!=0){
lastPageNum++;
}
if(pageCount!=lastPageNum){
%>
<a href="CustomerServlet?action=next&pageno=<%=pageCount+1%>">下一页</a>
<%
}
%>
<br>
共<%= lastPageNum %>页 ,当前第<%= pageCount %>页
<br>
<input type="hidden" value="addtocart" name="action">
<input type="submit" value="addtocart">
<%
}
%>
</form>
</body>
</html>
有哪位大牛给看看,到底哪儿出错了???
搜索更多相关主题的帖子:
网上商店 occurred content Vector result
----------------解决方案--------------------------------------------------------
有没有高手给看看,需要具体代码时说下
----------------解决方案--------------------------------------------------------
请将全部异常发过来看看
----------------解决方案--------------------------------------------------------