springMVC整合beetl3.0

spring+springMVC+mybatis+beetl

先保证ssm能够正常运行,无报错!初次学习,如有错误!请指证。

添加ibeetl的jar包

一。maven中pom.xml配置添加:

        <!--模板引擎,Beetl-->
        <dependency>
            <groupId>com.ibeetl</groupId>
            <artifactId>beetl</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

如果非maven工程,直接下载http://git.oschina.net/xiandafu/beetl2.0/attach_files

二。在源文件下添加beetl.properties属性文件,我添加的都是默认值,注意:(

RESOURCE.root= /WEB-INF/template/

)

#######默认配置
ENGINE=org.beetl.core.engine.FastRuntimeEngine
DELIMITER_PLACEHOLDER_START=${
DELIMITER_PLACEHOLDER_END=}
DELIMITER_STATEMENT_START=<%
DELIMITER_STATEMENT_END=%>
DIRECT_BYTE_OUTPUT = FALSE
HTML_TAG_SUPPORT = true
HTML_TAG_FLAG = #
HTML_TAG_BINDING_ATTRIBUTE = var,export
HTML_TAG_ATTR_CONVERT=org.beetl.core.text.DefaultAttributeNameConvert
NATIVE_CALL = TRUE
TEMPLATE_CHARSET = UTF-8
ERROR_HANDLER = org.beetl.core.ConsoleErrorHandler
NATIVE_SECUARTY_MANAGER= org.beetl.core.DefaultNativeSecurityManager
RESOURCE_LOADER=org.beetl.core.resource.ClasspathResourceLoader
MVC_STRICT = FALSE

### 资源配置,resource后的属性只限于特定ResourceLoader ####
#classpath 跟路径,与框架集成的时候,此配置会被框架代码覆盖而不能生效
#RESOURCE.root= /
#RESOURCE.root= /WEB-INF
RESOURCE.root= /WEB-INF/template/
#是否检测文件变化
RESOURCE.autoCheck = TRUE
#自定义脚本方法文件位置
RESOURCE.functionRoot = functions
#自定义脚本方法文件的后缀
RESOURCE.functionSuffix = html
#自定义标签文件位置
RESOURCE.tagRoot = htmltag
#自定义标签文件后缀
RESOURCE.tagSuffix = tag

#如果采用beetl集成的web应用,可以在渲染模板前调用如下类,此类必须实现WebRenderExt接口
WEBAPP_EXT =

#允许html function or Tag 使用特殊的定界符,因为function或者tag通常有大量beetl语句
FUNCTION_TAG_LIMITER=

#####  扩展,也可以通过特定框架注册##############
## 内置的方法
FN.date = org.beetl.ext.fn.DateFunction
FN.nvl = org.beetl.ext.fn.NVLFunction
FN.debug = org.beetl.ext.fn.DebugFunction
#兼容以前版本,用has代替
FN.exist = org.beetl.ext.fn.CheckExistFunction
FN.has = org.beetl.ext.fn.CheckExistFunction
FN.printf = org.beetl.ext.fn.Printf
FN.decode = org.beetl.ext.fn.DecodeFunction
FN.assert = org.beetl.ext.fn.AssertFunction
FN.print = org.beetl.ext.fn.Print
FN.println = org.beetl.ext.fn.Println
FN.printFile = org.beetl.ext.fn.PrintFile
FN.trunc = org.beetl.ext.fn.TruncFunction
FN.trim = org.beetl.ext.fn.TruncFunction2
FN.qmark = org.beetl.ext.fn.QuestionMark
FN.isEmpty = org.beetl.ext.fn.EmptyExpressionFunction
FN.isNotEmpty = org.beetl.ext.fn.IsNotEmptyExpressionFunction
FN.parseInt = org.beetl.ext.fn.ParseInt
FN.parseLong = org.beetl.ext.fn.ParseLong
FN.parseDouble= org.beetl.ext.fn.ParseDouble
FN.range = org.beetl.ext.fn.Range
FN.flush = org.beetl.ext.fn.Flush
FN.json = org.beetl.ext.fn.Json
FN.pageCtx = org.beetl.ext.fn.PageContextFunction
FN.type.new=org.beetl.ext.fn.TypeNewFunction
FN.type.name=org.beetl.ext.fn.TypeNameFunction
FN.global=org.beetl.ext.fn.DynamicGlobalValueFunction
FN.allGlobal=org.beetl.ext.fn.AllGlobaAsJsonlFunction
FN.hasAttribute=org.beetl.ext.fn.HasAttributeFunction
FN.env=org.beetl.ext.fn.EnvFunction
FN.parentTag=org.beetl.ext.fn.ParentTagFunction



##内置的功能包
FNP.strutil = org.beetl.ext.fn.StringUtil
FNP.reg = org.beetl.ext.fn.RegxFunctionUtil
FNP.array = org.beetl.ext.fn.ArrayUtil

##内置的格式化函数
FT.dateFormat =  org.beetl.ext.format.DateFormat
FT.numberFormat =  org.beetl.ext.format.NumberFormat
##内置的默认格式化函数
FTC.java.util.Date = org.beetl.ext.format.DateFormat
FTC.java.sql.Date = org.beetl.ext.format.DateFormat
FTC.java.sql.Time = org.beetl.ext.format.DateFormat
FTC.java.sql.Timestamp = org.beetl.ext.format.DateFormat
FTC.java.lang.Short = org.beetl.ext.format.NumberFormat
FTC.java.lang.Long = org.beetl.ext.format.NumberFormat
FTC.java.lang.Integer = org.beetl.ext.format.NumberFormat
FTC.java.lang.Float = org.beetl.ext.format.NumberFormat
FTC.java.lang.Double = org.beetl.ext.format.NumberFormat
FTC.java.math.BigInteger = org.beetl.ext.format.NumberFormat
FTC.java.math.BigDecimal = org.beetl.ext.format.NumberFormat
FTC.java.util.concurrent.atomic.AtomicLong = org.beetl.ext.format.NumberFormat
FTC.java.util.concurrent.atomic.AtomicInteger = org.beetl.ext.format.NumberFormat

##虚拟属性 无
## 标签类
TAG.include= org.beetl.ext.tag.IncludeTag
TAG.includeFileTemplate= org.beetl.ext.tag.IncludeTag
TAG.layout= org.beetl.ext.tag.LayoutTag
TAG.delete= org.beetl.ext.tag.DeleteTag
TAG.htmltag= org.beetl.core.tag.HTMLTagSupportWrapper
TAG.htmltagvar= org.beetl.core.tag.HTMLTagVarBindingWrapper
TAG.htmltagexport= org.beetl.core.tag.HTMLTagVarBindingWrapper
TAG.cache= org.beetl.ext.tag.cache.CacheTag
# 一个html风格的include和layout <#html:include file="">
TAG.html.include= org.beetl.ext.tag.IncludeResourceHtmlTag
TAG.html.layout= org.beetl.ext.tag.LayoutResourceHtmlTag
#TAG.includeUrl=org.beetl.ext.tag.IncludeUrlTag












三。spring-mvc.xml添加配置

1.注意JSP视图解析器添加顺序, <property name="order" value="256" />
2.beetl视图解析中viewNames的值,
        <property name="viewNames">
            <list>
                <value>**</value>
            </list>
        </property>

-----------------------------------------------------------------------------

<!--beetl配置-->
    <bean id="beetlConfig" class="org.beetl.ext.spring.BeetlGroupUtilConfiguration" init-method="init">
        <property name="configFileResource" value="classpath:beetl.properties"/>
    </bean>
    <bean id="viewResolver" class="org.beetl.ext.spring.BeetlSpringViewResolver">
        <property name="contentType" value="text/html;charset=UTF-8"/>
    </bean>
    <!-- Beetl视图解析器1 -->
    <bean name="beetlViewResolver" class="org.beetl.ext.spring.BeetlSpringViewResolver">
        <!-- 多视图解析器,需要设置viewNames和order -->
        <property name="viewNames">
            <list>
                <!--<value>/template/**</value>-->
                <value>**</value>
            </list>
        </property>
        <property name="suffix" value=".btl"/>
        <property name="contentType" value="text/html;charset=UTF-8"/>
        <property name="order" value="0"/>
        <!-- 多GroupTemplate,需要指定使用的bean -->
        <!--<property name="config" ref="beetlConfig"/>-->
    </bean>
    <!-- 配置视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
        <property name="order" value="256" />
    </bean>

文件目录:

控制层:

前台页面;

JSP页面

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值