Explain the directory structure
Original collation is not easy, reproduced please specify the Source: SPRINGMVC Multi-View Integrated configuration tutorial (JSP, Velocity, Freemarker)
Code Download Address: http://www.zuidaima.com/share/1751860803652608.htm
Spring configuration file
<?xml version= "1.0" encoding= "UTF-8"?> <beans "xmlns=" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:p= "http://www.springframework.org/schema/p" xmlns:context=
"Http://www.springframework.org/schema/context" xsi:schemalocation= "Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-3.0.xsd Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <context:component-scan
Base-package= "Com.spring.action"/> <!--org.springframework.web.servlet.view.ResourceBundleViewResolver
When used for multiple view integrations, resourcebundleviewresolver resolves the request output file by parsing the resource file. <property name= "basename" value= "views" ></property>, which means that there is a/web-inf/classes file under the views.properties path, In this case, the Views.properties content is welcome. (Class) =org.springframework.web.servlet.view.velocity.velocityview WELCOME.URL=WELCOME.VM freemarker. (Class) =org.springFramework.web.servlet.view.freemarker.FreeMarkerView FREEMARKER.URL=FREEMARKER.FTL--> <bean class= " Org.springframework.web.servlet.view.ResourceBundleViewResolver "> <property name=" basename "value=" views " ></property> <!--<property name= "order" value= "0" ></property>--> </bean> <! --JSP View parser--> <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 View parser--> <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> <!--veloci Ty Environment Configuration; <bean id= "Velocityconfig" class= "Org.springframework.web.servlet.view.velocity.VelocityConfigurer" > <!-- Velocity profile Path--> <property name= "configlocation" value= "/web-inf/velocity.properties"/> <!-- Velocity template path--> <property name= "Resourceloaderpath" value= "/web-inf/velocity/"/> </bean> <!--F Reemarker environment Configuration--> <bean id= "Freemarkerconfig" class= " Org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer "> <!--freemarker template location--> < Property Name= "Templateloaderpath" value= "/web-inf/freemarker/"/> </bean> <!--freemarker View Resolution--> & Lt;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"); In the welcome. (class) Fixed writing
welcome. ( Class) =org.springframework.web.servlet.view.velocity.velocityview
#welcome. URL path welcome.vm template name
WELCOME.URL=WELCOME.VM
#freemarker为modelAndView. Setviewname ("Freemarker"); In the Freemarker. (class) Fixed writing
Freemarker. ( Class) =org.springframework.web.servlet.view.freemarker.freemarkerview
#freemarker. URL path FREEMARKER.FTL template name
freemarker.url= FREEMARKER.FTL