开发者

Cannot use the "include file" in 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" %>

When I open the main.jsp, It sho开发者_StackOverflow中文版ws the error

cannot find the "jsp/list/universe/header.jsp"

the header.jsp and other classes cannot be read. Can anyone help me to solve the problem? thank you.

Class structure

webapp
|
|-- jsp
    |
    |-- list
    |   |
    |   |--main.jsp
    | 
    |-- universe
        |
        |-- header.jsp
        |-- footer.jsp


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).

So in this case you have to set the path either to ../universe/header.jsp or /jsp/universe/header.jsp.


In JSP include directive, path can be relative.

You can use it this way

<%@ include file="/jsp/universe/header.jsp" %>

You can refer the directives on many sites. Best one is sun java website.

Or you can visit this page Include Directive


It depends if your using the classpath to locate files. if your using classpath to locate your files then it should be inside your class folder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜