从非struts 2动作访问struts 2 jsp

时间:2010-02-03 07:34:54

标签: java struts2

我有一个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 jsp而不通过S2动作渲染

                **(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)

1 个答案:

答案 0 :(得分:0)

好的,直接使用struts 2标签是不可能的,但我得到了解决方法。

我们可以使用<iframes>来划分基于S2的部分。在iframe内部提供S2 url,并且视图可以与非基于S2的jsp一起呈现。