zoukankan      html  css  js  c++  java
  • 跟我学Spring Boot(二)Hello World

    1、打开DemoApplication添加如下代码

    package com.example;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    @Controller //1
    @SpringBootApplication
    public class DemoApplication {
    
        //2
        @RequestMapping("/helloboot")
        public String helloBoot(Model model){
            return "index";
        }
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }

    2、在resources/template/目录下新建index.html

    代码如下

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <title>Title</title>
    </head>
    <body>
    hello world
    </body>
    </html>

    这里需要注意的是meta 部分一定要有结束符不然后提示下面错误

    org.xml.sax.SAXParseException: 元素类型 "meta" 必须由匹配的结束标记 "</meta>" 终止。

  • 相关阅读:
    清除所有标签的属性
    chm提取
    视频分享
    依赖注入
    python-markdown
    light sdk
    ~
    html标签引入外部html
    微信公众平台自定义菜单
    还在为需要ajax而导入jquery吗? 纯js封装ajax操作
  • 原文地址:https://www.cnblogs.com/lvlv/p/6159740.html
Copyright © 2011-2022 走看看