一.listComment.jsp页面的一个超链接:<a href="<s:url action="listcomments" includeParams="none"/>">全部</a>
二.struts.xml内的一个action:<action name="listcomments" class="bookAction" method="listcomments">
                           <result>/listComment.jsp</result>
                         </action>
三.bookaction.java里的listcomments方法:public String listcomments()throws Exception{
if(queryMap ==null||queryMap.equals("")){

}else{
String[] str=queryMap.split("~");
this.setQueryName(str[0]);
this.setQueryValue(str[1]);
}

System.out.println("asd"+this.getQueryValue());
int totalRow=ics.getRows(this.getQueryName(),this.getQueryValue());//这里提示java.lang.NullPointerException
System.out.println(totalRow);
pager=pagerService.getPager(this.getCurrentPage(), this.getPagerMethod(), totalRow);
this.setCurrentPage(String.valueOf(pager.getCurrentPage()));
this.setTotalRows(String.valueOf(totalRow));
availableItems=ics.getComments(this.getQueryName(),this.getQueryValue(),pager.getPageSize(),  pager.getStartRow());

this.setQueryName(this.getQueryName());
this.setQueryValue(this.getQueryValue());

this.setSearchName(this.getQueryName());
this.setSearchValue(this.getQueryValue());
return SUCCESS;  
}
四.DAO中getRows的方法:public int getRows(String fieldname, String value) {
         String sql="";
         if(fieldname==null||fieldname.equals("")||fieldname==null||fieldname.equals(""))
        sql="FROM comments ORDER BY commentId";
         else
        sql="FROM comments where "+fieldname+" like '%"+value+"%'"+"ORDER BY commentId";
         List list=this.getHibernateTemplate().find(sql);
         return list.size();
               }
第一次使用SSH框架,请各位大虾指教!

解决方案 »

  1.   

    ics 这个是null 吧!
      

  2.   

    ics是业务逻辑层的一个接口,它的实现类实现了DAO下的getRows方法,也就是上面的第四点那个方法
      

  3.   

    我跟踪它好一会了,最后跟进数据库里面,发现竟找不到任何错误(究其原因,是个人技术太差了),于是在好一会后的现在,我心如刀绞,仰面泣血,声嘶力竭的狂嗷:HELP!……
      

  4.   

    测试下:
    System.out.println("asd"+this.getQueryValue()); // test...
    System.out.println("ics===" + ics);int totalRow=ics.getRows(this.getQueryName(),this.getQueryValue());//这里提示java.lang.NullPointerException 查看抛出来的错误堆栈信息。使用SSH,出现NullPointer,很多情况都是配置文件Ioc的问题
      

  5.   


    你debug下,看String[] str=queryMap.split("~")中的str[0]str[1],this.getQueryName(),this.getQueryValue()这几个是不是出现null了