tomcat 7.0을 사용하고 있습니다. 이제는 CSS 및 js 파일을로드 할 수없는 문제가 있습니다. $ {pageContext.request.contextPath}를 추가하려고했지만 작동하지 않습니다. 또한 c : url 태그를 시도했지만 eclipse에서 구문 오류가 발생했습니다.
이러한 파일 구조는 다음
의 WebContent
-content/CSS/lab3.css
HTML과 JS 폴더 여기서도
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>lab3</display-name>
<welcome-file-list>
<welcome-file>/content/html/lab3.html</welcome-file>
</welcome-file-list>
</web-app>
콘텐츠 폴더하에되는 HTML 헤드 :
<link rel="stylesheet" type= "text/css" href= "${pageContext.request.contextPath}/css/lab3.css" media="screen, projection">
식 '$ {pageContext.request.contextPath} '와 같은 것은 일반 HTML 파일에서 사용할 수 없으므로 JSP 파일 내에서 사용해야합니다. 먼저 자바 서블릿과 JSP에 대한 자습서를 읽어 보는 것이 좋습니다. –
@DavidLevesque 그래, 일반 HTML 파일에서 어떻게 위치에 액세스해야합니까? – Chwa
상대 경로를 사용할 수 있습니다. 예 :'href = "../ css/lab3.css" ' –