无法使用“包含文件"在JSP中 [英] Cannot use the "include file" in JSP
问题描述
我想问一个有关JSP页面的问题.为了有效地管理项目,我将项目设置为以下结构.当我在列表文件夹main.jsp中时,将标题设置为以下
I want to ask a question about the JSP page. I set the project in the following structure in order to manage the project efficiently. When I am in the list folder, main.jsp, I set the header as the following
<%@ include file="universe/header.jsp" %>
当我打开main.jsp时,它显示错误
When I open the main.jsp, It shows the error
找不到"jsp/list/universe/header.jsp"
cannot find the "jsp/list/universe/header.jsp"
header.jsp和其他类无法读取.谁能帮助我解决问题?谢谢.
the header.jsp and other classes cannot be read. Can anyone help me to solve the problem? thank you.
类结构
webapp
|
|-- jsp
|
|-- list
| |
| |--main.jsp
|
|-- universe
|
|-- header.jsp
|-- footer.jsp
推荐答案
在JSP包含指令中,路径可以相对于包含页面或绝对路径(然后它必须以/
开头并且属于Web应用程序根目录).目录).
In a JSP include directive the path can be relative to the including page or absolute (then it has to start with a /
and belongs to the webapplication root directory).
因此,在这种情况下,您必须将路径设置为../universe/header.jsp
或/jsp/universe/header.jsp
.
So in this case you have to set the path either to ../universe/header.jsp
or /jsp/universe/header.jsp
.
这篇关于无法使用“包含文件"在JSP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!