fremarker 基础

fremarker 基础

springboot 基础配置

server:
  port: 8088 #服务端口
  servlet:
    context-path: /test-freemarker

spring:
  application:
    name: test-freemarker #指定服务名
  freemarker:
    request-context-attribute: rc  #把Spring的RequestContext对象暴露为变量rc
    expose-request-attributes: true # 模板能够使用request请求参数
    expose-session-attributes: true # 模板能够使用 session 参数
    charset: UTF-8
    content-type: text/html
    suffix: .ftl # 解析文件后缀,也可以为 html
    enabled: true 
    template-loader-path: classpath:/templates/ # 模板解析目录,默认
    resources:
      add-mappings: false #关闭工程中默认的资源处理
    mvc:
      throw-exception-if-no-handler-found: true #出现错误时直接抛出异常

常见的request、session、context 获取属性值的

url请求参数值:${RequestParameters['param1']!""}<br/>
Request属性值 : ${Request['attr1']}<br/>
Session属性值 : ${Session['session1']}<br/>
contextPath: ${rc.contextPath}<br/>
请求地址: ${rc.requestUri}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值