servlet-context.xml에서 보면,

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
	<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> 라고 

자동으로 주석처리된 줄의 내용이 생성되는것을 볼 수 있는데, 

spring project의 webapp 폴더를 기준으로 매핑을 하겠다는 뜻으로 이해하면 되겠다.

 

그래서 가령, 아래와 같이 파일 위치를 지정했다면, servlet-context.xml에서 작성해야할 코드는 다음과 같다.

 

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
	<resources mapping="/resources/**" location="/resources/" />
	<resources mapping="/css/**" location="/resources/css" />

해석)

resources mapping (URI 매핑)에서 css가 있으면, webapp을 기준으로

/resources/css 폴더 밑에서 찾겠다는 뜻이 되겠다.

 

이제, list.jsp에서 외부 external css 파일을 참조하게 하고 싶을때, 다음 구문을 추가하면 된다. 

<link rel="stylesheet" href="${path}/resources/css/liststyle.css">

 

 

 

 

 

 

+ Recent posts