SPRINGMVC Multi-View Consolidated configuration tutorial (JSP, Velocity, Freemarker) __js

Source: Internet
Author: User

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&gt, 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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.