| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 881 人关注过本帖
标题:关于写基于mvc网上商店时出现的问题?
只看楼主 加入收藏
尘埃落雪
Rank: 2
等 级:论坛游民
帖 子:34
专家分:17
注 册:2010-6-7
结帖率:88.89%
收藏
 问题点数:0 回复次数:2 
关于写基于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)
 (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= "*"%>
<%!
    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">&nbsp;&nbsp;
                    <%
                                             }
                    %>
        </form>
                       
                    
    </body>
</html>

有哪位大牛给看看,到底哪儿出错了???
搜索更多相关主题的帖子: 网上商店 occurred content Vector result 
2011-11-06 18:34
尘埃落雪
Rank: 2
等 级:论坛游民
帖 子:34
专家分:17
注 册:2010-6-7
收藏
得分:0 
有没有高手给看看,需要具体代码时说下
2011-11-06 18:46
twqllq988495
Rank: 1
等 级:新手上路
帖 子:9
专家分:5
注 册:2011-11-10
收藏
得分:0 
请将全部异常发过来看看
2011-11-16 14:10
快速回复:关于写基于mvc网上商店时出现的问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036344 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved