<!-- jsp視圖解析器 -->
< bean id ="jspViewResolver" class ="org.springframework.web.servlet.view.InternalResourceViewResolver" >
< property name ="viewClass" value ="org.springframework.web.servlet.view.JstlView" />
< property name ="prefix" value ="/" />
< property name ="suffix" value =".jsp" />
</ bean >
<!-- velocity視圖解析器 -->
< bean id ="velocityViewResolver" class ="org.springframework.web.servlet.view.velocity.VelocityViewResolver" >
< property name ="cache" value ="true" />
< property name ="prefix" value ="/" />
< property name ="suffix" value =".vm" />
</ bean >
<!-- velocity環境配置 -->
< bean id ="velocityConfig" class ="org.springframework.web.servlet.view.velocity.VelocityConfigurer" >
<!-- velocity設定檔路徑 -->
< property name ="configLocation" value ="/WEB-INF/velocity.properties" />
<!-- velocity模板路徑 -->
< property name ="resourceLoaderPath" value ="/WEB-INF/velocity/" />
</ bean >
<!-- FreeMarker環境配置 -->
< bean id ="freemarkerConfig" class ="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer" >
<!-- freemarker模板位置 -->
< property name ="templateLoaderPath" value ="/WEB-INF/freemarker/" />
</ bean >
<!-- FreeMarker視圖解析 -->
< bean id ="freeMarkerViewResolver" class ="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver" >
< property name ="cache" value ="true" />
< property name ="prefix" value ="/" />
< property name ="suffix" value =".ftl" />
</ bean >
</ beans > views.properties
#welcome為modelAndView.setViewName( " welcome " ) ; 中的welcome .(class)固定寫法
welcome.(class) = org.springframework.web.servlet.view.velocity.VelocityView
#welcome.url 路徑 welcome.vm模板名稱
welcome.url = welcome.vm