viewResolver는 글자 앞뒤 잘라 붙이게 해주는 기능이 있다.
/WEB-INF/view/ 잘라서 앞에 붙이고
.jsp를 뒤에 붙일 것이다.




<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>

public class IndexController implements Controller{
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("index controller");
ModelAndView mv = new ModelAndView("index");
mv.addObject("data", "Hellow Spring MVC~");
//mv.setViewName("/WEB-INF/view/index.jsp");
return mv;
}
}

출처 :
https://www.youtube.com/watch?v=J0ZPjJ6-HC4&list=PLq8wAnVUcTFWhDFFmpJ5fUeoJI53Z83g6&index=9
'Spring' 카테고리의 다른 글
| Spring MVC (스프링 웹 MVC) 강의 10 - 정적파일 서비스하기 (0) | 2022.01.04 |
|---|---|
| Spring MVC (스프링 웹 MVC) 강의 09 - HTML 파일 설정하기 (0) | 2022.01.04 |
| Spring MVC (스프링 웹 MVC) 강의 07 - View 페이지를 위한 위치 (0) | 2022.01.04 |
| Spring MVC- dispatcher-servlet.xml 파일 오타 (0) | 2022.01.04 |
| STS4 JRE 추가 및 변경하기 (0) | 2022.01.03 |
댓글