기본적으로 스프링이 정적인 파일 서비스 불가능하게 막아 놨기 때문이다.
/ 는
JSP말고 정적인 파일 막게 된다.
/*
로 설정해 두면 JSP도 막힌다.
<mvc:~~~~>태그를 쓰기 위해
스키마 파일 등등 설정을 추가해줘야한다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd
">
<bean id="/index" class="com.newlecture.web.controller.IndexController">
<!-- collaborators and configuration for this bean go here -->
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<mvc:resources location="/resource" mapping="/resource/**"></mvc:resources>
</beans>
resource 폴더 생성
후 아무 이미지 파일 넣어서 실행해보면
정적파일 실행되는 걸 확인할 수 있다.
다시 html폴더로 넣고
html폴더명을 static으로 바꾼다
resource폴더 삭제
static이란 폴더 안에 정적인 파일들 다 모아둔다.
정적 이미지 실행하면 404에러가 뜬다
주소란에 static을 루트 취급하여 지우고 실행하면 404오류가 아닌 정상적으로 된다
그래서 최하단 index파일 실행하면
정상적으로 불러와진다.
출처:
https://www.youtube.com/watch?v=-YHVKPbkSoM&list=PLq8wAnVUcTFWhDFFmpJ5fUeoJI53Z83g6&index=11
'Spring' 카테고리의 다른 글
Spring MVC (스프링 웹 MVC) 강의 12 - Detail 컨트롤러 추가와 View 페이지 집중화의 필요성 (0) | 2022.01.04 |
---|---|
Spring MVC (스프링 웹 MVC) 강의 11 - 공지사항 컨트롤러 추가하기 (0) | 2022.01.04 |
Spring MVC (스프링 웹 MVC) 강의 09 - HTML 파일 설정하기 (0) | 2022.01.04 |
Spring MVC (스프링 웹 MVC) 강의 08 - ViewResolver 사용하기 (0) | 2022.01.04 |
Spring MVC (스프링 웹 MVC) 강의 07 - View 페이지를 위한 위치 (0) | 2022.01.04 |
댓글