pom.xml 에 dependency 추가
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.6.2</version>
</dependency>
velocity를 먼저 사용하기 위해 기존 InternalResourceViewResolver에 order를 추가하고 벨로시티 관련 설정 추가
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/view/" />
<beans:property name="suffix" value=".jsp" />
<beans:property name="order" value="2" />
</beans:bean>
<beans:bean id="velocityConfig"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<beans:property name="resourceLoaderPath" value="/WEB-INF/velocity/" />
</beans:bean>
<beans:bean id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<beans:property name="suffix" value=".vm" />
<beans:property name="order" value="1" />
</beans:bean>
* 테스트
control에 추가
@RequestMapping(value = "/hello", method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView mav = new ModelAndView();
mav.setViewName("hello");
mav.addObject("title","hello");
mav.addObject("body","hello");
return mav;
}
/WEB-INF/velocity/hello.vm 작성
<html>
<head>
<title>$title</title>
</head>
<body>
$body
</body>
</html>