1

我有一个 JSP,它使用<s:action>标签调用一个动作:

<s:form>
    <s:action name="myaction"
        namespace="/utente/include" executeResult="true"
        ignoreContextParams="true" var="formattazione" />
    
    //do something
</s:form>

调用动作myaction,我可以按照流程调试它。它完成得很好,没有错误,它返回成功,但是有一个错误,我不明白是哪一个。

动作定义:

<package name="utente-include" namespace="/utente/include" extends="tiles-default">
    
    <action name="myaction" class="com.emaborsa.doctracing.web.action.formattazione.FormattazioneCriteriUtenteAction"
        method="formattazione">
        <result type="tiles">mytiles.def</result>
    </action>
    
</package>

瓷砖定义:

<definition name="mytiles.def" template="/pages/empty.jsp">
    <put-attribute name="body" value="/pages/mypage.jsp"/>
</definition>

空的.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertAttribute name="body" />

例外:

GRAVE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
at org.apache.jsp.pages.utente.elencoUtenti_jsp._jspx_meth_s_005fif_005f0(elencoUtenti_jsp.java:215)
at org.apache.jsp.pages.utente.elencoUtenti_jsp._jspx_meth_s_005fform_005f0(elencoUtenti_jsp.java:155)
at org.apache.jsp.pages.utente.elencoUtenti_jsp._jspService(elencoUtenti_jsp.java:87)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
.....

编辑:

我认为它有效,但它没有。实际上系统并没有崩溃,但是邮件页面中没有包含tiles-page。我得到的例外:

org.apache.tiles.impl.CannotRenderException: No request dispatcher returned for path '/../pages/common/myPage.jsp'
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:680)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
at org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)

这里是我的 myPage.jsp(实际上写什么并不重要):

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<div class="navigazioneElenco" id="navigazioneElenco">

</div>

在这里,我分享我的项目的一部分。只有部分不工作... 下载

4

2 回答 2

0

可能此错误来自您的 jsp 页面。您可以发布 mypage.jsp 中可用的代码吗?或者手动检查你是否使用任何 scriptlet 标签可能会导致空指针异常。使用 struts 逻辑标签检查值。所以你可能不会遇到空指针异常。

于 2013-10-01T16:50:40.870 回答
0

解决了更新到Struts 2.3.15.2

于 2013-10-16T18:47:08.267 回答