spring에서 static 자원 사용하기 !
출처 : http://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something
[핵심 요약]
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/" />
test.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<h1>Page with image</h1>
<!-- use c:url to get the correct absolute path -->
<img src="<c:url value="/resources/img/image.jpg" />" />
위와 같이 서블릿 설정에서 고정자원 경로를 설정한 이후 VIEW에서 c:url 을 활용하면 된다.
(그냥 링크 대신 c:url을 활용하면 해당 app name (배포 경로)가 포함되기 때문에 link오류가 발생하지 않음.)
'etc > old' 카테고리의 다른 글
[Java] Spring 406 not acceptable / @RequestBody @ResponseBody (0) | 2013.03.06 |
---|---|
[Java] No mapping found for HTTP request with URI [/favicon.ico] in spring (0) | 2013.03.04 |
[Java] url-pattern에서 / 와 /*의 차이점 (0) | 2013.02.27 |
[Java] Ubuntu 12.04에서 apache2 + tomcat7 mod_jk 연동처리 (0) | 2012.12.24 |
[ETC] Asus P8H77-V Linux 네트워크 설정 (0) | 2012.12.14 |