Spring MVC:在视图内部包含一个JSP(JSP安装在视图旁边,因此无法从外部控制器访问)? [英] Spring MVC: Including a JSP inside a view (JSP is installed next to view so is inaccesible from outside controller)?

查看:41
本文介绍了Spring MVC:在视图内部包含一个JSP(JSP安装在视图旁边,因此无法从外部控制器访问)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个视图,并且视图运行良好,但是现在我需要在页面中包含另一个JSP.

I have created a view and its working well but i now need to Include another JSP inside the page.

考虑到我的视图安装在WEB-INF/Views的保护区域中(因此,在我的img,css所在的资源目录中不可用)

Considering my views are installed in the protected area of WEB-INF/Views (hence its not available in my resources directory where my imgs, css are)

我尝试使用

   <%@ include file="/views/shared/items/NewItem.jsp" %>

考虑到我的NewItem.jsp是与其他视图一起安装的(即不能通过常规路径访问,而是由控制器控制),它总是给我FileNotFound,我如何才能包括安装在我旁边的JSP文件查看

And it always gives me FileNotFound, taking into consideration that my NewItem.jsp is installed with my other views (i.e. NOT accesible via the normal routes but controlled by controllers) how can i include a JSP files that is installed next to my view

如果我取出包含文件",我的视图将呈现没有问题.

If i take out the "include file" my view renders without issues.

我确定我在这里缺少什么吗?

I am sure i am missing something here?

预先感谢

推荐答案

如果/WEB-INF/views/shared/items/NewItem.jsp位于/WEB-INF/views/shared/items/NewItem.jsp中,则在插入它时必须使用此路径:

If NewItem.jsp is in /WEB-INF/views/shared/items/NewItem.jsp, then you have to use this path when incuding it:

<%@ include file="/WEB-INF/views/shared/items/NewItem.jsp" %>

这篇关于Spring MVC:在视图内部包含一个JSP(JSP安装在视图旁边,因此无法从外部控制器访问)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆