博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring boot: freemarket模板引擎
阅读量:7301 次
发布时间:2019-06-30

本文共 3902 字,大约阅读时间需要 13 分钟。

spring boot: freemarket模板引擎

freemarket模板引擎,可以和thymeleaf模板引擎共存

pom.xml引入

org.springframework.boot
spring-boot-starter-freemarker

  

 

appliationContext.properties配置

####################################################FREEMARKET#################################################spring.freemarker.allow-request-override=falsespring.freemarker.cache=falsespring.freemarker.check-template-location=truespring.freemarker.charset=UTF-8spring.freemarker.content-type=text/htmlspring.freemarker.expose-request-attributes=falsespring.freemarker.expose-session-attributes=falsespring.freemarker.expose-spring-macro-helpers=false#spring.freemarker.prefix=#spring.freemarker.request-context-attribute=#spring.freemarker.settings.*=spring.freemarker.suffix=.ftlspring.freemarker.template-loader-path=classpath:/templates/ #comma-separated list#spring.freemarker.view-names= # whitelist of view names that can be resolved

  

OrderController.JAVA控制器文件

package com.muyang.boot22.controller;import java.util.Map;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controller@RequestMapping(value="/order")public class OrderController {			@RequestMapping(value="/index")	public String index(Map
map) { map.put("name", "张三"); return "order/index"; } @RequestMapping(value="/list") public String list(Map
map) { map.put("name", "张三"); map.put("age", 25); map.put("gender", "男"); return "order/list"; } }

  

view文件

order/list.ftl

freemark-list

freemarket-list

name: ${name}
age: ${age}
gender: ${gender}

  

pom.xml参考

4.0.0
com.muyang
boot22
0.0.1-SNAPSHOT
jar
boot22
http://maven.apache.org
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
UTF-8
1.8
org.springframework.boot
spring-boot-starter-web
javax.servlet
jstl
junit
junit
3.8.1
test
mysql
mysql-connector-java
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-thymeleaf
org.springframework.boot
spring-boot-starter-freemarker
com.alibaba
fastjson
1.2.15
org.springframework.boot
spring-boot-devtools
true
true
org.springframework.boot
spring-boot-maven-plugin
true

  

 

 

访问路径

http://localhost:8081/springboot/order/index

http://localhost:8081/springboot/order/list

 

转载地址:http://obfnm.baihongyu.com/

你可能感兴趣的文章
《大道至简》第二章(是懒人创造了方法)读后感
查看>>
【database】database domain knowledge
查看>>
UVa 455 - Periodic Strings
查看>>
使用JDBC连接数据库
查看>>
20172307 2017-2018-2 《程序设计与数据结构》第6周学习总结
查看>>
c#中使用多线程访问winform中控件的若干问题
查看>>
strong_alias && weak_alias && __attribute__
查看>>
js中三个对数组操作的函数 indexOf()方法 filter筛选 forEach遍历 map遍历
查看>>
Histogram Equalization(直方图均衡化)
查看>>
string::substr()简介
查看>>
[LeetCode] Permutations II
查看>>
献给我老公 - Java枚举类型
查看>>
Hadoop简介
查看>>
AD9857和ADS5542昨天调试通过了。
查看>>
MySQL点滴
查看>>
Servlet学习笔记03——什么是DAO?
查看>>
AOJ673 聪明的输入法(字典树)
查看>>
Github常见错误
查看>>
板子集合
查看>>
第四十一课、编辑交互功能的实现------------------狄泰软件学院
查看>>