最近在做一个小项目,一个很简单的功能:
把Mysql数据库的一个表加载到Flexigrid控件中,所有代码都完成了,本店测试接收字符串正确,Flexigrid正常显示
一到Tomcat中调用Action就报NullPointException,异常信息还没有指出问题在哪儿,不能打印出接收字符串,所以不能显示
代码如下: <script type="text/javascript">
        $(fgInit);
        function fgInit(){            $("#flexigrid1").flexigrid
              (
                {
               url: '<%=basePath%>back/showUser.action',
               method:'post',
              dataType: 'json',
              colModel : [
              {display: 'ID', name : 'id', width : 50, sortable : true, align: 'center'},
            {display: '用户名', name : 'name', width : 100, sortable : true, align: 'center'},
           {display: '密码', name : 'pwd', width : 80, sortable : true, align: 'center'},
               {display: '类型', name : 'type', width : 60, sortable : true, align: 'center'},
              {display: '出生日期', name : 'birth', width : 100, sortable : true, align: 'center'},
       {display: '资金', name : 'money', width : 80, sortable : true, align: 'center'},
       { display: '修改', name: 'modify', width: 50, sortable: false, align: 'center' },
          { display: '删除', name: 'delete', width: 50, sortable: false, align: 'center' }
            ],
          buttons : [
            {name: '添加', bclass: 'add', onpress : btClick},
               {name: '删除', bclass: 'delete', onpress : btClick},
             {name: '修改', bclass: 'modify', onpress : btClick},
              {separator: true}
            ],
           searchitems : [
                  {display: '用户名', name : 'name', isdefault: true},
                   {display: '用户ID', name : 'id'}                       ],
                    sortname: "id",
                    sortorder: "desc",
                    resizable:true,
                    usepager: true,
                    title: '用户管理',
                    errormsg: '发生错误',
                    pagestat: '共有{total}条记录,显示{from}到{to}',
                    nomsg: '没有符合条件的记录存在',
                    procmsg: '正在加载数据,请稍等...',
                  useRp: true,
                    striped:true,
                    rp:5,
                    rpOptions: [3,5,10],
                   showTableToggleBtn: false,
                    showToggleBtn:false,
                    width: 590,
                     height: 250                     }
                    );
showUser.action
 public String showUser()  {
        try{
               List users = DAOService.getListByEq(TUser.class,new String[]{"*",""});//问题就在这句出异常
         setJsonStr(DAOService.ListToFlexiGridJSON(users, rp,page));
       System.out.println(jsonStr);
     response.setContentType("text/html;charset=utf-8");
     response.getWriter().write(jsonStr);
        }catch (Exception e){
            System.out.println(e);
        e.printStackTrace();}
        return SUCCESS;
     }getListByEq方法 这个方法本地测试正常,能输出正确的字串,但Action一调用就报NullPointException  public static List getListByEq(Class class1, String[] term) throws Exception {                Session     session     = sessionFactory.openSession();
        Transaction transaction =null;        List list =null;
        try{
       transaction = session.beginTransaction();
        Criteria    c1          = term[0].equals("*")
                                  ? session.createCriteria(class1)
                                  : session.createCriteria(class1).add(Restrictions.eq(term[0], term[1]));
          list    = c1.list();        transaction.commit();
        }catch (Exception e){
           transaction.rollback();
            throw e;
        }finally {
            session.close();
          //  sessionFactory.close();
        }
Exception 如下
java.lang.NullPointerException
at services.DAOService.getListByEq(DAOService.java:194)
at actions.Manage.showUser(Manage.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept
......................
还有就是Tomcat会报
严重: The web application [/voting] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@377e2a]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1332b63]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 以上我在网上查了很久,方法都无效,请哪位大侠相救,想给100分但我一共就20分,没办法