1. ?xml version="1.0"encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="
  7. http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  11. <context:component-scan
  12. base-package="com.spring.action" />
  13. <!--
  14. org.springframework.web.servlet.view.ResourceBundleViewResolver
  15. 用于多个视图集成时,ResourceBundleViewResolver是通过解析资源文件来解析请求输出文件的。
  16. <property name="basename"value="views"></property>,即表示在/WEB-INF/classes路径下有一个
  17. views.properties文件,本例中views.properties的内容为
  18. welcome.(class)=org.springframework.web.servlet.view.velocity.VelocityView
  19. welcome.url=welcome.vm
  20. freemarker.(class)=org.springframework.web.servlet.view.freemarker.FreeMarkerView
  21. freemarker.url=freemarker.ftl
  22. -->
  23. <bean class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
  24. <property name="basename" value="views"></property>
  25. <!--
  26. <property name="order"value="0"></property>
  27. -->
  28. </bean>
  29. <!-- jsp视图解析器 -->
  30. <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  31. <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
  32. <property name="prefix" value="/"/>
  33. <property name="suffix" value=".jsp"/>
  34. </bean>
  35. <!-- velocity视图解析器 -->
  36. <bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
  37. <property name="cache" value="true"/>
  38. <property name="prefix" value="/"/>
  39. <property name="suffix" value=".vm"/>
  40. </bean>
  41. <!-- velocity环境配置 -->
  42. <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
  43. <!-- velocity配置文件路径 -->
  44. <property name="configLocation" value="/WEB-INF/velocity.properties"/>
  45. <!-- velocity模板路径 -->
  46. <property name="resourceLoaderPath" value="/WEB-INF/velocity/"/>
  47. </bean>
  48. <!-- FreeMarker环境配置 -->
  49. <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
  50. <!-- freemarker模板位置 -->
  51. <property name="templateLoaderPath" value="/WEB-INF/freemarker/"/>
  52. </bean>
  53. <!-- FreeMarker视图解析 -->
  54. <bean id="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
  55. <property name="cache" value="true"/>
  56. <property name="prefix" value="/"/>
  57. <property name="suffix" value=".ftl" />
  58. </bean>
  59. </beans>

SpringMvc多视图配置(jsp、velocity、freemarker) velocity在springmvc.xml配置VelocityViewResolver,VelocityConfigurer,FreeMarkerConfigurer,FreeMarkerViewResolver的更多相关文章

  1. springmvc 配置多视图(jsp,freemarker,HTML等)

    SpringMVC 的 Controller 可以返回各种各样的视图.比如 JSP, JSON, Velocity, FreeMarker, XML, PDF, Excel, 还有Html字符流 等等 ...

  2. SpringMVC 学习 八 SSM环境搭建(一) web.xml配置

    第一步:导入jar包 注意包的兼容性,以后采用maven会好很多 第二步:配置web.xml 在web.xml中,主要的配置内容有以下几点 (1)spring容器配置文件的位置 <!-- spr ...

  3. SpringMVC源码分析6:SpringMVC的视图解析原理

    title: SpringMVC源码分析6:SpringMVC的视图解析原理 date: 2018-06-07 11:03:19 tags: - SpringMVC categories: - 后端 ...

  4. 使用纯注解与配置类开发springMVC项目,去掉xml配置

    最近拜读了杨开振老师的书,深入浅出springBoot2.x,挖掘了很多以前被忽略的知识, 开发一年多,工作中一直用传统springmvc的开发,基本都还是用的传统的xml配置开发, 看到书里有提到, ...

  5. springmvc.xml和applicationContext.xml配置的特点

    1:springmvc.xml配置要点 一般它主要配置Controller的组件扫描器和视图解析器 下为:springmvc.xml文件 <?xml version="1.0" ...

  6. spring 5.x 系列第1篇 —— springmvc基础 (xml配置方式)

    文章目录 一.搭建hello spring工程 1.1 项目搭建 1.2 相关配置讲解 二.配置自定义拦截器 三.全局异常处理 四.参数绑定 4.1 参数绑定 4.2 关于日期格式转换的三种方法 五. ...

  7. SpringMVC、SpringMVC XML配置(纯XML方式)

    1.引入SrpingMVC所使用的Java包: cglib-nodep-2.1_3.jar.commons-logging.jar.spring-aspects-4.1.7.RELEASE.jar.s ...

  8. SpringBoot零XML配置的Spring Boot Application

    Spring Boot 提供了一种统一的方式来管理应用的配置,允许开发人员使用属性properties文件.YAML 文件.环境变量和命令行参数来定义优先级不同的配置值.零XML配置的Spring B ...

  9. Sping MVC不使用任何注解处理(jQuery)Ajax请求(基于XML配置)

    1. Spring Spring框架是一个轻量级的解决方案,是一个潜在的一站式商店,用于构建企业就绪的应用程序.Spring框架是一个Java平台,为开发Java应用程序提供全面的基础架构支持.Spr ...

  10. struts2 实现过程和xml配置

    实现过程: 当Web容器收到 请求(HttpServletRequest)它将请求传递给一个标准的的过滤链包括 (ActionContextCleanUp)过滤器,然后经过Other filters( ...

随机推荐

  1. PHP 关于timezone问题

    Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use ...

  2. angular实现的文字上下无缝滚动

    最近在学习angularJs,业余时间随便写了一个文字上下无缝滚动的例子,主要写了一个小小的指令. css代码:主要控制样式 <style type="text/css"&g ...

  3. ImageView最大高度和宽度失效解决方案

    解决方案 做RecyclerView的 item 布局时,用到imageview ,可是图片按原始尺寸显示,不规范. 所以去google了一下imageview的宽高限制,就试了下maxheight/ ...

  4. JVM-3.内存

    目录 一.运行时数据区 二.内存使用细节:以HotSpot的堆为例 三.实战:OutOfMemoryError异常 四.垃圾收集器(堆+方法区)与内存分配策略       一.运行时数据区 1.程序计 ...

  5. vue使用Axios做ajax请求

    vue2.0之后,就不再对vue-resource更新,而是推荐使用axios 1. 安装 axios $ npm install axios 或 $ bower install axios 2. 在 ...

  6. Common.Logging源码解析二

    Common.Logging源码解析一分析了LogManager主入口的整个逻辑,其中第二步生成日志实例工厂类接口分析的很模糊,本随笔将会详细讲解整个日志实例工厂类接口的生成过程! (1).关于如何生 ...

  7. Bootstrap 常用组件汇总

    Bootstrap 官方文档:http://www.bootcss.com/ Bootstrap Multiselect 多选下拉组件 官方文档:http://www.kuitao8.com/demo ...

  8. Java线程间通信之wait/notify

    Java中的wait/notify/notifyAll可用来实现线程间通信,是Object类的方法,这三个方法都是native方法,是平台相关的,常用来实现生产者/消费者模式.我们来看下相关定义: w ...

  9. cat和tac的用法

    1.cat和tac的功能 cat从前往后显示文本文件内容tac与cat相反,从后往前显示文本文件内容 2.cat用法 $cat [-AbEnTv] [filename]选项与参数:-A :相当于 -v ...

  10. Ubuntu下录音机程序的使用

    在Ubuntu中使用系统自带的录音机程序可以录制电脑的音频输出(比如,电脑正在播放视频的声音),或录制外部环境音频输入(比如,自己说话的声音) 1.录制电脑音频输出 在“硬件”选项中,将”选中设备的设 ...