JavaEE 之 SpringBoot

來源:互聯網
上載者:User

標籤:color   ring   輸入   static   set   root   org   resources   username   

1.Springboot

  a.定義:Spring Boot是由Pivotal團隊提供的全新架構,其設計目的是用來簡化新Spring應用的初始搭建以及開發過程

  b.約定目錄結構:(Maven的資源檔目錄/src/java/resources中)

      spring-boot項目靜態檔案目錄:/src/java/resources/static(一般放img、css、js等)

      spring-boot項目模板檔案目錄:/src/java/resources/templates(一般放html檔案)

 

 

2.使用

  a.Controller中

    @GetMapping("/")    //輸入路徑http://127.0.0.1:8080/ 即可訪問到    public String index(){        return "index";    }    @GetMapping("/loginPapge")    public String loginPapge(){        return "login";    }

  b.html中

<!DOCTYPE html><html lang="en"  xmlns:th="http://www.thymeleaf.org"><head>    <meta charset="UTF-8"/>    <title>Title</title></head><body>歡迎你:<span th:text="${session.user.getUserName()}"></span>    <table>        <tr>            <th>id</th>            <th>姓名</th>            <th>密碼</th>            <th>狀態</th>        </tr>        <tr  th:each="user,userStat: ${users}">            <td th:text="${user.userId}"></td>            <td th:text="${user.userName}"></td>            <td th:text="${user.userPwd}"></td>            <td th:text="${user.userType}"></td>        </tr>    </table></body></html>

  c.如需使用Spring Data Jpa,需在/src/java/resources中配置application.yml

spring:  thymeleaf:    cache: false  datasource:    username: root    url: jdbc:mysql://127.0.0.1:3306/j135    driver-class-name: com.mysql.jdbc.Driver    password: admin  jpa:    show-sql: true    database-platform: org.hibernate.dialect.MySQL5Dialect

 

    

JavaEE 之 SpringBoot

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.