thymeleaf配置使用

1yml配置

spring:
 thymeleaf:
  suffix: .html
  prefix: classpath:/templates/
  cache: false
  encoding: UTF-8
  content-type: text/html
  mode: HTML5

注意 要在 src\main\resources路径下新建templates文件夹
2 Controller向页面传值

package com.game.controller.mobile;


import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class TestController {
	protected final Logger logger = Logger.getLogger(this.getClass());
	@RequestMapping(value = "/test", method = {RequestMethod. POST ,RequestMethod. GET })
	public String test(HttpServletRequest request) {
		request.setAttribute("info", "enterGameMoblie调用异常");
		return "err.html";// src\main\resources/templates/err.html
		
	}
}

3 html接收






    err
    





	

访问测试

你可能感兴趣的:(springboot,thymeleaf,springboot)