我第一次搭 struts2 + spring +hibernate的框架
我想做一个全查询。Action里代码:
  public String searchAll(){
List list = biz.searchAll();
request.setAttribute("allUser", list);
return SUCCESS;
}调试程序走到biz.searchAll();时候按F6跳入一个Invocation TargetException.class文件的下面方法
 public InvocationTargetException(Throwable target) {
super((Throwable)null);  // Disallow initCause
        this.target = target;
    }然后就报错了,如下图,请问这是为什么啊?是我框架搭的又问题吗?在控制台什么错也没报,页面跳转成功了,但是跳转到的页面没有得到request传递过来的值,大家帮我看看,谢谢了~

解决方案 »

  1.   

    说明那个searchAll();方法有问题,所以跳到了程序一场基类里面了
      

  2.   

    我把我的几个文件粘贴上来,可能是配置的又问题~ 大家帮忙看看~ 谢谢了
    web.xml:配置
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    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">

      <!-- 配置监听器 -->
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param> <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

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

  3.   

    struts.xml:配置
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
            "http://struts.apache.org/dtds/struts-2.0.dtd">
            
    <struts>
    <package name="struts2a" extends="struts-default">
    <action name="searchAll" class="com.se.web.action.UserAction" method="searchAll">
    <result type="redirect">/index.jsp</result>
    </action>
    </package>
    </struts>
      

  4.   

    applictionContext.xml:配置
    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation"
    value="classpath:hibernate.cfg.xml">
    </property>
    </bean>

    <bean id="UsersDAO" class="com.se.dao.UsersDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>

    <bean id="UsersBIZ" class="com.se.service.impl.userService">
    <property name="dao">
    <ref bean="UsersDAO" />
    </property>
    </bean>

    <bean id="UsersAction" class="com.se.web.action.UserAction">
    <property name="biz">
    <ref bean="UsersBIZ" />
    </property>
    </bean>

    </beans>
      

  5.   

    <result type="redirect">/index.jsp</result>
    你的里面的type我觉得有点错哈。因为redirect表示重新定向,取数据的话肯定是去不出来的,改为dispacher或者不写type那一项!!
      

  6.   

    我自己找到错误了....  我struts.xml里 action的结点的class写错了  应该是applicationContext.xml 里action那个bean结点的 id值....  不过还是谢谢大家了~