2 qq 37011270 qq_37011270 于 2017.08.31 14:10 提问

Servlet mybaits的问题

package com.company.servlet;

import java.util.List;

import me.gacl.domain.Card;
import me.gacl.domain.Clazz;
import me.gacl.domain.FKSqlSessionFactory;
import me.gacl.domain.Person;
import me.gacl.domain.Student;
import me.gacl.domain.User;

import org.apache.ibatis.session.SqlSession;

public class Ttt {
public void ttt(){
SqlSession test = FKSqlSessionFactory.getSqlSession();
List cards=test.selectList("me.gacl.mapping.personMapper.selectpersons");
for(int i=0;i<cards.size();i++){
Card card=cards.get(i);
for(int j=0;j<card.getPersons().size();j++){
Person p=card.getPersons().get(j);
System.out.println(p.getId()+","+p.getName()+","+p.getSex()+","+p.getCard_id()+":::"+card.getCode());
}
}
test.commit();
test.close();

}
public static void main(String[] args) {
Ttt ttt=new Ttt();
ttt.ttt();

}

}
这样调用是可以的

但是我在servlet里面调用Ttt的ttt方法他就会报错
初学mybaits,想把servlet和她结合起来
求帮助感激不尽 3q

Servlet.service() for servlet [MainServlet] in context with path [/FcSuiShou] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoClassDefFoundError: Could not initialize class me.gacl.domain.FKSqlSessionFactory

web.xml
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<filter>
    <filter-name>ManagerValidateFilter</filter-name>
    <filter-class>com.company.filter.ManagerValidateFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>ManagerValidateFilter</filter-name>
    <!-- 过滤manager子目录下的所有资源 -->
    <url-pattern>/manager/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<servlet>
    <servlet-name>MainServlet</servlet-name>
    <servlet-class>com.company.servlet.MainServlet</servlet-class> 
    <load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>MainServlet</servlet-name>
    <url-pattern>/main.do</url-pattern>
</servlet-mapping>




<resource-ref>
    <description>DB Connection pool</description>
    <res-ref-name>jdbc/companyDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Csdn user default icon
上传中...
上传图片
插入图片