Struts 2 包含标签
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 include 指令
Try it with include directive