auto_import="/common/index.ftl" as ui 这个表示每个freemarker的视图页面都会自动引入这个ftl文件。里面定义的就是一些宏,如text文本框,各种form元素,此处不多做解释,会freemarker的都知道,这里只讲spring3mvc 配置freemarker视图。
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
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
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<mvc:annotation-driven />
<!-- 支持 @AspectJ 标记-->
<aop:aspectj-autoproxy proxy-target-class="true"/>
<context:component-scan base-package="code.main.bean.controller" />
<!--此处对应urlrewrite里面的配置,就是一些静态文件的存放目录,可以直接加载,原来spring rest里面会把这里也拦截掉,页面加载不了图片,js,样式表之类的 ,这个是3.0.4之后出来的标签
<rule> <from>/resources/**</from> <to>/resources/$1</to> </rule>
上面这些就是urlrewrite.xml的配置。
-->
<mvc:resources location="/resources/" mapping="/resources/**" />
<context:component-scan base-package="code.main.bean.aop">
<context:include-filter type="annotation" expression="org.aspectj.lang.annotation.Aspect"/>
</context:component-scan>
<!-- 使用注解映射 -->
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
</bean>
<!-- 让springmvc支持文件上传 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxInMemorySize" value="2048"></property>
<property name="maxUploadSize" value="1000000000"/>
<property name="uploadTempDir" value="tmoDir"></property>
</bean>
<!-- 让controller 返回json的配置 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<util:list id="beanList">
<ref bean="mappingJacksonHttpMessageConverter" />
</util:list>
</property>
</bean>
<!--配置freemarker视图重点配置 -->
<bean id="freemarkerResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="order" value="1" />
<property name="prefix" value="" /> <!--前缀-->
<property name="suffix" value=".html" /><!--后缀-->
<property name="contentType" value="text/html;charset=utf-8" /><!--编码-->
<property name="viewClass">
<value>
org.springframework.web.servlet.view.freemarker.FreeMarkerView
</value>
</property>
<!-- 上下文,这里配置之后,fkt文件中可以使用${rc.getContextPath()} 来获取文件上下文,类似jsp的request.getContextPath() -->
<property name="requestContextAttribute" value="rc"></property>
<!--
如果freemarker自定义函数的话:有个属性 attributesMap这个属性,里面支持方一个map,key-value的方式来定义你的自定义函数。
类要实现freemarker提供的接口。
-->
</bean>
<!-- 这里定义freemarker.properties文件的加载,和后面的对应。 -->
<bean id="freemarkerConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:freemarker.properties"/>
</bean>
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="defaultEncoding" value="UTF-8" />
<property name="templateLoaderPath" value="/WEB-INF/pages"/> <!-- 模板加载路径 -->
<property name="freemarkerSettings" ref="freemarkerConfiguration"/>
</bean>
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</beans>
相关推荐
spring MVC + freeMarker spring MVC + freeMarker spring MVC + freeMarker
Spring 3 mvc + Freemarker 的例子
Spring3MVC以Freemarker作展示层简单示例
最新spring3 mvc restful urlrewrite jquery json freemarker整合架构jar图片,欢迎下载: 说明比较少,群号:24172014,不懂来问,已懂讨论
3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 4、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于...
源码 博文链接:https://lavafree.iteye.com/blog/1096699
基于springboot+mvc+freemarker+aop实现校友信息管理系统.zip基于springboot+mvc+freemarker+aop实现校友信息管理系统.zip基于springboot+mvc+freemarker+aop实现校友信息管理系统.zip基于springboot+mvc+freemarker...
spring mvc +freemarker不错的mvc搭配 原文: http://lavafree.iteye.com/blog/1096699 一、原来的程序有问题,导致maven无法编译运行。修改后解决了maven无法编译打包运行的问题,运行通过。 1.pom.xml 增加了必需的...
NULL 博文链接:https://yjmyd1119.iteye.com/blog/1452904
spring mvc freemarker 简单例子
这个jar文件包含Spring MVC框架相关的所有类。 包含国际化、标签、Theme、视图展现的FreeMarker、JasperReports、Tiles、Velocity、XSLT相关类。 当然,如果你的应用使用了独立的MVC框架,则无需这个JAR文件里的...
spring mvc freemarker 自定义标签demo spring mvc 通过自定义的标签在jsp页面调用,初学,记录下做个备忘
spring mvc 3.0、mybatis3、freemarker2.3整合,
camel-freemarker-1.6.4.jar, camel-freemarker-2.8.1.jar, ...freemarker-1.4.1.jar, freemarker-2-3-18.jar, freemarker-2.1.5.jar, freemarker-2.2.5.jar, freemarker-2.2.8.jar,...freemarker.jar, freemarker2_03.jar
Spring mvc+hibernate+freemarker(开源项目)
freemarker与struts2详细配置.
com.jagregory.shiro.freemarker.ShiroTags 已经打包过的权限标签,可直接使用
Spring MVC框架的架构,并在这样的高度可配置的方式,每一块的逻辑和功能设计。 此外Spring可以毫不费力地与其他流行的Web框架,如Struts,WebWork的,的Java Server Faces和Tapestry集成。 这意味着,你甚至可以...
NULL 博文链接:https://bijian1013.iteye.com/blog/2259056
spring mvc 3.2 + mybatis3.2 + jsp + jstl + jquery + OSCache + freeMarker + mysql 用户登陆用统一的认证登陆接口:shiro; 前台用freeMarker 模板,还有 jsp!