springboot 集成freemarker
来源:互联网 发布:linux用户加组 编辑:程序博客网 时间:2024/06/06 12:26
接着上一篇(springboot应用搭建及简单介绍)继续搞,之前已经搭起了springboot的架子,接下来是集成freemarker,这样一个最简单的web项目就有了。
首先需要在pom里面加入freemarker的依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId></dependency>然后在src/main/resources目录下建一个template的目录,之后可以把页面放到这里面,新建application.properties,添加如下内容
spring.freemarker.suffix=.ftlspring.freemarker.templateEncoding=UTF-8spring.freemarker.templateLoaderPath=classpath:/templates/定义一个controller,写一个index的方法,如下
@Controllerpublic class IndexController {@RequestMapping(value = { "index", "/" })public String index() {return "index";// template目录下页面文件名}}启动访问http://localhost:8080/ 就可以看到对应的页面了
源码
git clone https://github.com/cm-jornada/demo.gitgit checkout freemarker
spring.freemarker.allow-request-override=false # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name.spring.freemarker.allow-session-override=false # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name.spring.freemarker.cache=false # Enable template caching.spring.freemarker.charset=UTF-8 # Template encoding.spring.freemarker.check-template-location=true # Check that the templates location exists.spring.freemarker.content-type=text/html # Content-Type value.spring.freemarker.enabled=true # Enable MVC view resolution for this technology.spring.freemarker.expose-request-attributes=false # Set whether all request attributes should be added to the model prior to merging with the template.spring.freemarker.expose-session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template.spring.freemarker.expose-spring-macro-helpers=true # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext".spring.freemarker.prefer-file-system-access=true # Prefer file system access for template loading. File system access enables hot detection of template changes.spring.freemarker.prefix= # Prefix that gets prepended to view names when building a URL.spring.freemarker.request-context-attribute= # Name of the RequestContext attribute for all views.spring.freemarker.settings.*= # Well-known FreeMarker keys which will be passed to FreeMarker's Configuration.spring.freemarker.suffix= # Suffix that gets appended to view names when building a URL.spring.freemarker.template-loader-path=classpath:/templates/ # Comma-separated list of template paths.spring.freemarker.view-names= # White list of view names that can be resolved.
阅读全文
0 0
- springboot 集成freemarker
- springboot采用FreeMarker模板集成应用
- springboot +nginx +freemarker 模板的简单集成
- 从0开始学习SpringCould(4)--SpringBoot 集成freemarker
- FreeMarker集成
- springboot整合freemarker
- springboot使用Freemarker继承
- springboot整合freemarker
- SpringBoot和freemarker整合
- springboot整合freemarker
- SpringBoot整合freemarker
- springboot整合freemarker
- SpringMVC,springboot,freemarker笔记
- Springboot整合freemarker
- springboot整合jd freemarker
- springboot+freemarker国际化
- SpringBoot入门-10(springboot配置freemarker模板)
- Spring框架集成FreeMarker
- CSS可继承的样式
- 微信小程序周报(第七期)
- 网络流建模总结
- POJ 2250 Compromise(最长公共子序列 列出子序列)
- 新路程------hi3516a uboot测试网络是否正常
- springboot 集成freemarker
- CodeForces 711 E.ZS and The Birthday Paradox(组合数学)
- 网络爬虫的简介
- Linux下安装Tomcat服务器和部署Web应用
- 51C中_nop_(); 指令的说明和作用
- static 和 self的区别
- win10 + vs2013 +caffe 简易CPUonly安装步骤
- Common lisp编译成C可执行文件
- IDEA开发spring mvc 报404错误