当我请求操作时,是什么导致了此 NPE?

What's causing this NPE when I request an action?

提问人:agaonsindhe 提问时间:10/18/2012 最后编辑:agaonsindhe 更新时间:11/10/2023 访问量:7216

问:

当我第一次运行我的程序时,这个错误不存在,然后我尝试了一些实验来获得 MVC 架构的流程,但现在它向我展示了这个异常。

我想问题是当我通过订阅按钮请求时,它会转到它将寻找操作的位置。问题出在包装标签中应该有什么struts.xml

java.lang.NullPointerException
    org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:501)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:432)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:619)

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>
    <constant name="struts.devMode" value="true" />
    <!--  This package --> 
    <package name="Struts2Ex2" extends="struts.default">
        <action name="test"
            class="MyPack.Verify"
            method="execute">
            <result name="success">/Test2/WelcomeHome.jsp</result>
        </action>
    </package>
 </struts>
java struts2 nullpointerexception xml 配置

评论

1赞 agaonsindhe 10/18/2012
我在包装标签中得到了它应该是的解决方案'extends=“struts-default”' 而不是 'extends=“struts.default”'
3赞 Dave Newton 10/18/2012
请回答问题,而不是评论。

答:

4赞 Roman C 10/19/2012 #1

错误包括: 1.在XML使用中没有这样的注释。 2.没有这样的包使用。/* */<!-- -->struts.defaultstruts-default

0赞 agaonsindhe 6/17/2017 #2

我在包装标签中得到了它应该是的解决方案'extends=“struts-default”' 而不是 'extends=“struts.default”'