效果图

代码

package com.wls.integrateplugs.hello.controller;

/**
* Created by wls on 2017/8/24.
*/
import java.util.Locale;
import java.util.UUID; import javax.servlet.http.HttpSession; import com.sun.org.apache.regexp.internal.RE;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore; @RestController
public class HelloController { @RequestMapping(value = "/hello",method = RequestMethod.GET)
public String hello(Locale locale, Model model) {
return "hello world";
} @RequestMapping("/helloWorld")
public String index() {
return "Hello World";
} /**
* 使用@RestController时,则使用ModelAndView显示页面
* @param map
* @return
*/
@ApiIgnore
@RequestMapping(value = "/helloThymeleaf",method = RequestMethod.GET)
public ModelAndView indexThymeleaf(ModelMap map) {
ModelAndView mv = new ModelAndView("indexThymeleaf");
map.addAttribute("name","王老师");
map.addAttribute("host", "http://blog.didispace.com");
return mv;
} @RequestMapping(value = "/helloFreeMarker",method = RequestMethod.GET)
public ModelAndView indexFreeMarker(ModelMap map) {
ModelAndView mv = new ModelAndView("indexFreeMarker");
map.addAttribute("name","王老师");
map.addAttribute("host", "http://blog.didispace.com");
return mv;
} /**
* 共享session
* @param session
* @return
*/
@RequestMapping(value = "/uid",method = RequestMethod.GET)
String uid(HttpSession session) {
UUID uid = (UUID) session.getAttribute("uid");
if (uid == null) {
uid = UUID.randomUUID();
}
session.setAttribute("uid", uid);
return session.getId();
} }

  indexFreeMarker.ftl

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
<body>
FreeMarker模板引擎
<h1>${host}</h1>
</body>
</html>

  

<!--    freemarker      -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

  

最新文章

  1. linux init 启动顺序
  2. chrome快捷键,让开发更快捷:
  3. OC知识梳理-NSArray与NSMutableArray相关知识
  4. android 学习随笔九(网络:简单新闻客户端实现)
  5. Entityframework Code First 系列之数据注释
  6. *[hackerrank]Consecutive Subsequences
  7. jquery mobile validation
  8. bzoj 2815 [ZJOI2012]灾难(构造,树形DP)
  9. 委托学习续:Action、Func和Predicate
  10. 电子科大POJ &quot;3*3矩阵的乘法&quot;
  11. sql相关操作
  12. 【一天一道LeetCode】#9. Palindrome Number
  13. python 中list的深拷贝和浅拷贝
  14. Maven 错误 :The POM for com.xxx:jar:0.0.1-SNAPSHOT is invalid, transitive dependencies (if any) will not be available
  15. Luogu3119 草鉴定-Tarjan+Topsort
  16. Spark代码Eclipse远程调试
  17. javaScript中用eval()方法转换json对象
  18. vue中使用定时器时this指向问题
  19. excel 如何为列添加指定内容(字符串)
  20. python--logging库学习_自我总结---有空完善

热门文章

  1. centos初始化安装
  2. Java 父类、静态、子类执行顺序
  3. 阻塞队列之六:LinkedBlockingDeque
  4. POJ 2991 Crane(线段树)
  5. mysql 存储过程简单学习
  6. 10g RAC常用开启关闭命令 – SRVCTL用法
  7. webDriver对element进行操作
  8. cinder-backup详细介绍
  9. Rhythmk 一步一步学 JAVA(4):Spring MVC -之拦截器
  10. [转] FTP主动模式和被动模式的区别