从非 struts 2 操作访问 struts 2 jsp

发布于 2024-08-20 19:18:08 字数 2256 浏览 1 评论 0原文

我有一个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)

I have a servlet which takes us to an existing jsp, say "home.jsp". This is composed of many jspf fragments. So struture is like

Home.jsp includes jsp1, jsp2 and so forth.

Now we have part of modules migrated to struts2 and have a "new.jsp" (uses struts2 tags) which we need to include inside "home.jsp".
To achieve this I have placed

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

which returns the "new.jsp" as result.

but when I hit the sevlet , during rendering I get exception about the struts 2 FilterDispatcher. The exception trail is attached.

Please clarify if (1) Is this possible to render a S2 jsp while not rendering it via S2 action

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

The following is the exception trace :

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦回旧景 2024-08-27 19:18:08

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

我们可以使用 来划分基于 S2 的部分。在 iframe 内提供 S2 url 可以工作,并且视图可以与非基于 S2 的 jsp 结合呈现。

ok, It was not possible to use the struts 2 tags directly, but I got a work around.

We can use <iframes> to divide the sections which are S2 based. Providing a S2 url inside the iframe works and the view can be rendered in conjunction with the non S2 based jsp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文