parsecer :
이 같은 디렉토리 구조를 가지고 :
포함하는 시도 header.jsp
에서 home.jsp
이 같은 :
<%--
Created by IntelliJ IDEA.
User: Irina
Date: 31.03.20
Time: 20:58
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<jsp:include page="${pageContext.request.contextPath}/shared/header.jsp" />
<a href="${pageContext.request.contextPath}/login">Login</a>
<a href="${pageContext.request.contextPath}/signup">Signup</a>
</body>
</html>
실패 org.apache.jasper.JasperException: javax.servlet.ServletException: File [/comediansapp/shared/header.jsp] not found
오류입니다. 내가 뭘 잘못하고 있어요?
vladwoguer :
현재 페이지에 상대적인 경로를 제공합니다. 시험:
<jsp:include page="shared/header.jsp"/>
${pageContext.request.contextPath}
귀하의 경우 응용 프로그램의 현재의 contextPath는 comediansapp 는 경로에있는 파일을 찾아보십시오 있도록 /comediansapp/shared/header.jsp을
확인하시기 바랍니다 : https://stackoverflow.com/a/5850406/4325878
내가 시도하는 것이 전체 예제 :
index.jsp를
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<jsp:include page="shared/header.jsp" />
<a href="${pageContext.request.contextPath}/login.jsp">Login</a>
<a href="${pageContext.request.contextPath}/signup.jsp">Signup</a>
</body>
</html>
공유 / header.jsp를
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<nav style="height:50px; background:red;">
<strong> JSP!!! </strong>
</nav>