thymeleaf 加载h5界面的框架

1 依赖

<!--thymeleafj加载h5界面框架-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

2 controller代码

@Controller()
@RequestMapping("pager")//添加“/”与不添加一样,都会是默认有个“/”
public class PageController {
    // notice:   通过 http://localhost:8080/pager/index访问该方法
    // notice:   @ResponseBody:表示该方法的返回结果直接写入HTTP response body中
    // notice:  在使用@RequestMapping后,返回值通常解析为跳转路径
    // notice:  加上@esponsebody后返回结果不会被解析为跳转路径,而是直接写入HTTP response body中。
    // notice:  比如异步获取json数据,加上@Responsebody后,会直接返回json数据。该注解一般会配合@RequestMapping一起使用
    //notice 需要用到theamleaf框架加载h5页面,否则加载不出来
    @RequestMapping("/index")
    public String index() {
        return "index";
    }
}

3 html界面

<span style="font-size:18px;"><strong><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Title</title>
</head>
<body>
这是能运行在TomCat的一个index页面
</body>
</html></strong></span>
经验分享 程序员 微信小程序 职场和发展