강의

멘토링

커뮤니티

Inflearn Community Q&A

dmswo1062522's profile image
dmswo1062522

asked

Spring MVC Part 1 - Core technologies for backend web development

Hello Servlet

index.html문의

Written on

·

339

3

무료강의인 스프링 입문강의를 들었을때, 강사님께서 매핑되는 html화면이 없을경우에는 resource -> static -> index.html을 자동으로 찾아서 화면에 띄어준다고 하셨는데요

꼭 resource -> static 안에 없어도 되는건가요?

이번 강의에서는 main -> webapp -> index.html경로에 있는데 welcome페이지로 index.html이 동작하길레요

springMVC

Answer 2

3

yh님의 프로필 이미지
yh
Instructor

안녕하세요. 은재님

War 방식에서는 이 경로를 사용하는 것이 맞고,

조금 뒤에 Jar 방식을 사용하는데, 여기서는 resource -> static에 넣어주어야 합니다.

War 방식은 최근에 거의 사용하지 않으니 참고만 해주세요. 강의에서도 조금만 있으면 War 방식에서 Jar 방식으로 변경합니다.

감사합니다.

0

servlet-context.xml 에서 뷰 리졸버를 설정 해줘야 페이지가 열려요

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<beans:property name="prefix" value="/static/" />

<beans:property name="suffix" value=".html" />

</beans:bean>

prefix 부분에 index.html 가 있는 경로의 앞 부분을 적어주시고

suffix 부분에 index 뒤 확장자 부분을 적어주시면 됩니다.

예를 들면 /src/main/webapp/static/index.html 이라면

webapp 이후 경로 /static/ 을 적어주시고 index.html 의 확장자 .html을 적어주시면 깔끔하게 잘 나올꺼예여

dmswo1062522's profile image
dmswo1062522

asked

Ask a question