zoukankan      html  css  js  c++  java
  • springboot controller templates html

    首先声明:

      @Controller注解的类必须要在启动类的子集目录下,否则无法扫描

    本文要求:

      通过controller层跳转页面到html页面(本篇用到thymeleaf模板)

    项目结构展示:

    第一步:pom.xml

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

    第二步:application.properties(最后两条可加可不加)

    server.port=9999
    server.servlet.context-path=/
    server.tomcat.uri-encoding=UTF-8
    spring.thymeleaf.prefix=classpath:/templates/
    #spring.thymeleaf.suffix=.html
    #spring.thymeleaf.cache=false

    第三步:m3.html(随便写写)

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    video{
    100%;
    height: 100%;
    }
    </style>
    </head>
    <body>
    <h1>helloword</h1>
    <video src="videos/working-man.mp4" muted="" autoplay="" loop=""></video>
    </body>
    </html>

    第四步:controller

    @Controller
    public class HomePage {
    //, produces = "application/json;charset=utf-8"
    @RequestMapping(value = "/index")
    public String index(){
    return "m3";
    }
    }

    实现图片:(谷歌地址栏录入:localhost:9999/index

     

    总结:

    花非花,梦非梦,蝶非蝶,雨非雨,让渺远的梵音穿透天空,直到天之外。伸手,握不住岁月的苍凉。

    欢迎大佬留言

    
    
    





  • 相关阅读:
    uni-app中使用Echarts绘画图表
    css设置Overflow实现隐藏滚动条的同时又可以滚动
    JS判断在哪一端浏览器打开
    ElementUI分页Pagination自动到第一页
    第203场周赛
    TreeSet使用
    155 最小栈
    234 回文链表
    141 环形链表
    2 两数相加
  • 原文地址:https://www.cnblogs.com/dfym80/p/12849383.html
Copyright © 2011-2022 走看看