Struts 2 包含标签

发布于 2024-11-01 18:53:26 字数 616 浏览 1 评论 0原文

我在 java webapp 的同一个文件夹中有两个 JSP 文件。我们将它们称为index.jsp 和myInclude.jsp。我想将 myInclude.jsp 包含在 index.jsp 中。 Web 应用程序不是在 ROOT uri 中提供服务,而是在单独的 Web 应用程序(例如 /adminWebapp/)之外提供服务。

在index.jsp 中,我有以下内容:

<s:include value="myInclude.jsp" />

当我尝试访问index.jsp 时,Struts 抛出以下异常:

Exception thrown during include of myInclude.jsp
java.io.FileNotFoundException: /myInclude.jsp

问题是Struts 2 的include 标记在包含文件的URL 前面添加了一个“/”。如果Struts 2想要使用绝对路径(而不是相对路径),则需要调用/adminWebapp/myInclude.jsp。是否有任何选项可以修复 s:include 标签?我希望避免将 /adminWebapp 硬编码到链接中,以防我们移动 Web 应用程序。

I have two JSP files in the same folder on a java webapp. Let's call them index.jsp and myInclude.jsp. I want to include myInclude.jsp inside index.jsp. The webapp is not being served in the ROOT uri, but out of a separate webapp (such as /adminWebapp/).

In index.jsp, I have the following:

<s:include value="myInclude.jsp" />

When I try to access index.jsp, Struts throws the following exception:

Exception thrown during include of myInclude.jsp
java.io.FileNotFoundException: /myInclude.jsp

The trouble is that Struts 2's include tag added a "/" in front of the URL to the included file. If Struts 2 wants to use an absolute path (instead of relative), it would need to call /adminWebapp/myInclude.jsp. Is there any option which could fix the s:include tag? I'm hoping to avoid hard-coding the /adminWebapp into the link in case we ever move the webapp.

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

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

发布评论

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

评论(1

无语# 2024-11-08 18:53:26

尝试使用 include 指令

<%@ include file = "xxx" %>

Try it with include directive

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