Spring Boot学习(四)之web开发渲染页面 -- Velocity
来源:互联网 发布:sketchup看图软件 编辑:程序博客网 时间:2024/06/05 07:20
上篇编写了Spring Boot学习(四)之web开发渲染页面 -- Freemarker
接下来简单介绍一下Velocity整合,跟Freemarker是一样的,没有什么太大区别
下面开始看pol. xml引入的jar
需把
1
<dependencies>
2
<dependency>
3
<groupId>org.springframework.boot</groupId>
4
<artifactId>spring-boot-starter-freemarker</artifactId>
5
</dependency>
6
</dependencies>
替换为
1
<dependency>
2
<groupId>org.springframework.boot</groupId>
3
<artifactId>spring-boot-starter-velocity</artifactId>
4
</dependency>
index.ftl改为index.vm
内容为:
01
<!DOCTYPE html>
02
<
html
>
03
<
head
lang
=
"en"
>
04
<
meta
charset
=
"UTF-8"
/>
05
<
title
></
title
>
06
</
head
>
07
<
body
>
08
Velocity模板
09
<
h1
>${name}</
h1
>
10
</
body
>
11
</
html
>
启动项目:
访问http://localhost:8080/
结果显示为:
筱进GG
在spring boot的application.properties属性文件中为velocity提供了一些常用的配置,如下:
01
spring.velocity.allow-request-override=false # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name.
02
spring.velocity.allow-session-override=false # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name.
03
spring.velocity.cache= # Enable template caching.
04
spring.velocity.charset=UTF-8 # Template encoding.
05
spring.velocity.check-template-location=true # Check that the templates location exists.
06
spring.velocity.content-type=text/html # Content-Type value.
07
spring.velocity.date-tool-attribute= # Name of the DateTool helper object to expose in the Velocity context of the view.
08
spring.velocity.enabled=true # Enable MVC view resolution for this technology.
09
spring.velocity.expose-request-attributes=false # Set whether all request attributes should be added to the model prior to merging with the template.
10
spring.velocity.expose-session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template.
11
spring.velocity.expose-spring-macro-helpers=true # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext".
12
spring.velocity.number-tool-attribute= # Name of the NumberTool helper object to expose in the Velocity context of the view.
13
spring.velocity.prefer-file-system-access=true # Prefer file system access for template loading. File system access enables hot detection of template changes.
14
spring.velocity.prefix= # Prefix that gets prepended to view names when building a URL.
15
spring.velocity.properties.*= # Additional velocity properties.
16
spring.velocity.request-context-attribute= # Name of the RequestContext attribute for all views.
17
spring.velocity.resource-loader-path=classpath:/templates/ # Template path.
18
spring.velocity.suffix=.vm # Suffix that gets appended to view names when building a URL.
19
spring.velocity.toolbox-config-location= # Velocity Toolbox config location. For instance `/WEB-INF/toolbox.xml`
20
spring.velocity.view-names= # White list of view names that can be resolved.
就大功搞成了,这个跟freemarker差不多不做过多的介绍了!
欢迎大家一起交流学习SpringBoot,java等领域的技术,交流群 : 587674051 博客的源码也在里面
阅读全文
0 0
- Spring Boot学习(四)之web开发渲染页面 -- Velocity
- Spring Boot学习(四)之web开发渲染页面 -- Thymeleaf
- Spring Boot学习(四)之web开发渲染页面 -- Freemarker
- spring boot框架学习9-spring boot的web开发(5)-错误解决及跳转页面
- Spring Boot 教程(四) -- 开发 Web 应用
- Spring学习笔记之渲染Web视图
- Java Web开发之集成Spring Boot
- Spring Boot系列之二 Web开发
- spring boot之web开发(二)
- Spring Boot 使用 FreeMarker 渲染页面
- Spring Boot学习(四)
- 使用Spring Boot开发WEB页面(转载)
- spring boot关联velocity
- Spring渲染Velocity模版实例
- Spring Boot学习之旅:(四)springboot 整合 fastjson
- spring boot之集成页面
- Spring Boot的Web开发
- spring boot开发web应用
- Namespace Mapping
- python学习—Day20—模块:logging、os、command、sys
- 修改jar内容并重新打包为jar
- 处理时间戳
- 斐波那契数列的两种实现呢
- Spring Boot学习(四)之web开发渲染页面 -- Velocity
- python判断list是否为空
- 面向对象程序设计上机练习十(运算符重载)
- 修改注册表解决 Win7 DbgView 不显示调试信息
- Notepad++快捷键
- XList的集成使用+AsyncTask
- 阿里云搭建SS代理超详细教程!!!
- Ryu控制器代码解析-任意地址Ping应答
- uva124