일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 부트스트랩
- 성적프로그램
- Oracle DB
- Bootstrap
- Oracle SQL
- tomcat
- 답변형 게시판
- github
- JSP
- JavaScript
- rownum
- sql developer
- 과정평가형
- distinct
- alias
- git
- 제약조건
- ||
- Java
- HTTP Status 500
- CRUD
- SQL
- group by
- oracle
- jQuery
- HTTP Status 404
- 이클립스
- HTML
- 한글 인코딩
- 모조칼럼
Archives
초급의 끄적거림
[Spring] Static Resources 매핑 본문
검색을 진행한 이유
- 부트스트랩을 얹으려고 하는데 자꾸 정적 경로를 받아오지 못하고 아래와 같은 경고 발생
org.springframework.web.servlet.DispatcherServlet noHandlerFound
경고: No mapping found for HTTP request with URI ~~~~~~~~
문제 상태 해결 전 세팅
- *.js와 *.css 파일 처럼 정적인 리소스들을 처리하기 위해서 Resources 매핑이 필요함
- 요청 설정이 시작 되는 web.xml에 다른 xml 문서들이 매핑 되어 있고 현재 프로젝트에는 'data-dispatcher-servlet.xml'을 매핑해둔 상태였음
<!-- web.xml -->
<servlet>
<servlet-name>data-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/data-dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>data-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
- src/main/webapp/WEB-INF/spring/data-dispatcher-servlet.xml 에는 resources를 위한 경로를 추가해둔 상태
<resources mapping="/resources/**" location="/resources/" />
수정방법
위 사진과 같은 경로이기 때문에 resources를 분리해서 적어줌
경로 :: /src/main/webapp/resources/~~~
<resources mapping="/resources/**" location="/resources/" />
<resources mapping="/assets/**" location="/resources/assets/" />
<resources mapping="/Doc/**" location="/resources/Doc/" />
결과적으로 /assets/main.css 라는 요청이 들어오면 /resources/assets/main.css로 연결 시켜준다.
즉, mapping으로 들어온 요청에 대해 location으로 매핑시켜줌.
'Framework > Spring' 카테고리의 다른 글
[Spring] 오류 'mvc:annotation-driven' 요소에 대한 선언을 찾을 수 없습니다. (0) | 2021.04.14 |
---|---|
[어노테이션] @RequestMapping / @RequestParam (0) | 2020.07.03 |
[Spring] Tomcat version 8.5 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5, 6, and 7 Web modules (0) | 2020.04.26 |
[Spring] 애플리케이션 계층 / 단일 책임 원칙 (0) | 2020.04.21 |
[Spring] project configuration is not up-to-date with pom.xml (0) | 2020.04.12 |
Comments