微服务,微架构[十一]springboot模板页面velocity
来源:互联网 发布:java互联网开发框架 编辑:程序博客网 时间:2024/05/29 04:22
springboot可以集成很多模板文件来实现访问页面,今天我们主要介绍velocity的集成方式,很多集成模板页面都是大同小异
一、加入依赖pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>
二、控制器访问页面
package com.didispace.web;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.ui.ModelMap;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;/**** @author e生态* @version 1.0.0* @blog http://blog.csdn.net/ysl_228**/@Controllerpublic class HelloController { @RequestMapping("/hello") @ResponseBody public String hello() { return "Hello World"; } @RequestMapping("/") public String index(ModelMap map) { map.addAttribute("host", "http://blog.csdn.net/ysl_228"); return "index"; }}
三、页面内容,默认读取路径是resource/template/index.vm
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" /> <title></title></head><body>Velocity模板<h1>${host}</h1></body></html>
阅读全文
0 0
- 微服务,微架构[十一]springboot模板页面velocity
- 微服务,微架构[十一]springboot模板页面thymeleaf
- 微服务,微架构[十]springboot模板页面freemarker
- SpringBoot开始微服务架构
- 微服务,微架构[一]之springboot[helloWorld]
- 微服务,微架构[二]之springboot集成jdbc
- 微服务,微架构[四]之springboot集成Redis缓存
- 微服务,微架构[五]之springboot读取properties文件
- 微服务,微架构[六]之springboot集成mybatis
- 微服务,微架构[零]springboot入门介绍
- 微服务,微架构[七]之springboot异常处理
- 微服务,微架构[八]springboot多环境切换profiles
- 微服务,微架构[十二]springboot监听器,过滤器
- 微服务,微架构[十三]springboot集成RabbitMQ
- SpringBoot快速构建微服务架构体系
- 基于SpringBoot的微服务架构实践
- SpringBoot的Velocity模板文件
- 微服务,微架构[三]之springboot集成nosql数据库mongodb
- Hibernate 遇到的问题(1)
- 20170530心情总结
- 【转】使用Docker搭建hadoop集群
- 【Linux】互斥锁
- Java8之Lambda
- 微服务,微架构[十一]springboot模板页面velocity
- 小型聊天程序
- 工作紧张的5月
- Handler机制
- 53. Maximum Subarray Easy
- [openGL超级宝典][笔记][8.1缓冲区]
- 还原二叉树 (8分)
- Linux fork(),vfork(),clone()底层浅谈
- java类加载