》》》》idea中在项目多模块下springboot 整合thymeleaf ,进行web浏览显示《《《《

一.新建项目:03-spt-thymeleaf

1.1 新建pom文件

    
    
      org.springframework.boot
      spring-boot-starter-web
    
    
    
      org.springframework.boot
      spring-boot-starter-thymeleaf
    

1.2 新建controller层

package com.ljf.spring.boot.demo.thymeleaf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @ClassName: LoginController
 * @Description: TODO
 * @Author: liujianfu
 * @Date: 2020/08/06 11:50:46
 * @Version: V1.0
 **/
@Controller
public class LoginController {
    @RequestMapping("/show")
    public String showInfo(Model model){
        model.addAttribute("msg", "Thymeleaf 第一个案例");
        return "index";
    }
}

1.3 新建启动类

package com.ljf.spring.boot.demo.thymeleaf;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Hello world!
 *
 */
@SpringBootApplication
public class App 
{
    public static void main( String[] args )
    {

        SpringApplication.run(App.class, args);
        System.out.println("整个thymeleaf启动程序完成!!!");
    }
}

1.4 新建资源配置类

在resources文件夹下新建templates文件夹,新建index.html,内容如下:





Thymeleaf入门


	
	

1.5 访问结果:

》》》》idea中在项目多模块下springboot 整合thymeleaf ,进行web浏览显示《《《《_第1张图片

你可能感兴趣的:(springboot)