首页 > 编程语言 > 详细

struts2与struts1整合,java.lang.InstantiationException, Exception occurred during processing request: null

时间:2014-06-21 10:58:01      阅读:513      评论:0      收藏:0      [点我收藏+]

做了2个action,其中一个运行没有问题,另一个报错,看下面的报错信息,再看了看struts.xml,因为没有给GetBooks这个action配置actionform,所以就导致报null。下面是有问题的struts.xml,其中主要的问题就是没有给GetBooks这个action配置actionform,也就是没有添加那个interceptor-ref name="integration",添加上就好了(这个form在应用的逻辑里面,GetBooks是不需要form的,但是可能是由于struts2和struts1整合的时候要求每个action都必须有form,所以我就随便给GetBooks这个action配置了一个form,在GetBooks这个action里面不使用那个form就行了)

<?xml version="1.0" encoding="GBK" ?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <constant name="struts.i18n.encoding" value="GBK"/>
    <constant name="struts.custom.i18n.resources" value="messageResource"/>


    <package name="lee" extends="struts1-default" namespace="/test">
        <interceptors>
            <interceptor name="loginForm" 
                class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
                <param name="className">lee.LoginForm</param>
                <param name="name">loginForm</param>
            </interceptor>        
            <interceptor-stack name="integration">
                <interceptor-ref name="staticParams"/>
                <interceptor-ref name="loginForm"/>
                <interceptor-ref name="modelDriven"/>
                <interceptor-ref name="actionForm-reset"/>
                <interceptor-ref name="basicStack"/>
                <interceptor-ref name="actionForm-validation"/>
                <interceptor-ref name="workflow"/>
            </interceptor-stack>
        </interceptors>

        <action name="Login" class="org.apache.struts2.s1.Struts1Action">
            <param name="className">lee.LoginAction</param>
            <result name="success">welcome.jsp</result>
            <result name="error">error.jsp</result>
            <interceptor-ref name="integration" />
        </action>

        <action name="GetBooks" class="org.apache.struts2.s1.Struts1Action">
            <param name="className">lee.GetBooksAction</param>
            <result name="login">login.jsp</result>
            <result name="success">showBook.jsp</result>
        </action>
    </package>

</struts>    
    

 

严重: Exception occurred during processing request: null
java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:182)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:171)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.resolveModel(ScopedModelDrivenInterceptor.java:106)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:136)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:744)

struts2与struts1整合,java.lang.InstantiationException, Exception occurred during processing request: null,布布扣,bubuko.com

struts2与struts1整合,java.lang.InstantiationException, Exception occurred during processing request: null

原文:http://www.cnblogs.com/qrlozte/p/3794896.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!