SPRINGMVC Integrated Jsp,freemarker,velocity

Source: Internet
Author: User
Explain the directory structure

Spring configuration file XML version= "1.0" encoding= "UTF-8"?>
< beans xmlns = "Http://www.springframework.org/schema/beans"
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 under the/web-inf/classes path there is a
Views.properties file, 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 >

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

<!--freemarker 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-->
< 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 wording
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 wording
Freemarker. (Class) = Org.springframework.web.servlet.view.freemarker.FreeMarkerView
#freemarker. URL path FREEMARKER.FTL template name
Freemarker.url = FREEMARKER.FTL Welcome to add my QQ technology Group 425783133
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.