【问题标题】:Accessing struts 2 jsp from non-struts 2 action从非 struts 2 动作访问 struts 2 jsp
【发布时间】:2010-02-03 07:34:54
【问题描述】:

我有一个 servlet,它将我们带到一个现有的 jsp,比如“home.jsp”。这是由许多jspf片段组成的。所以结构就像

Home.jsp 包括 jsp1、jsp2 等。

现在我们已经将部分模块迁移到 struts2 并有一个“new.jsp”(使用 struts2 标记),我们需要将其包含在“home.jsp”中。 为了实现这一点,我已经放置了

<s:action namespace="/home" name="showNewJsp" executeResult="true"/>

返回“new.jsp”作为结果。

但是当我点击 sevlet 时,在渲染过程中我得到了关于 struts 2 FilterDispatcher 的异常。附上异常线索。

请说明(1)是否可以在不通过 S2 操作渲染的情况下渲染 S2 jsp

                **(2)** any thing is missing ?

以下是异常跟踪:

The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
    at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
    at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
    at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
    at org.apache.jsp.matterhome_jsp._jspx_meth_s_005faction_005f0(matterhome_jsp.java:5021)
    at org.apache.jsp.matterhome_jsp._jspService(matterhome_jsp.java:1339)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)

【问题讨论】:

    标签: java struts2


    【解决方案1】:

    好的,直接使用struts 2标签是不可能的,但我有一个解决办法。

    我们可以使用&lt;iframes&gt; 来划分基于 S2 的部分。在 iframe 中提供 S2 url 可以工作,并且可以与非基于 S2 的 jsp 一起呈现视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-03
      • 2013-12-07
      • 1970-01-01
      相关资源
      最近更新 更多