diff --git a/8.Spring-Boot-Thymeleaf/pom.xml b/8.Spring-Boot-Thymeleaf/pom.xml new file mode 100644 index 0000000..c9cd7fc --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + com.springboot + Spring-Boot-Thymeleaf + 0.0.1-SNAPSHOT + jar + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.5.9.RELEASE + + + + + UTF-8 + UTF-8 + 1.7 + 3.0.2.RELEASE + 2.0.1 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/Application.java b/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/Application.java new file mode 100644 index 0000000..a66ea9f --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/Application.java @@ -0,0 +1,13 @@ +package com.springboot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class,args); + } +} diff --git a/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/bean/Account.java b/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/bean/Account.java new file mode 100644 index 0000000..2eaa335 --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/bean/Account.java @@ -0,0 +1,49 @@ +package com.springboot.bean; + +public class Account { + private String account; + private String name; + private String password; + private String accountType; + private String tel; + + public Account(String account, String name, String password, String accountType, String tel) { + super(); + this.account = account; + this.name = name; + this.password = password; + this.accountType = accountType; + this.tel = tel; + } + public String getAccount() { + return account; + } + public void setAccount(String account) { + this.account = account; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public String getAccountType() { + return accountType; + } + public void setAccountType(String accountType) { + this.accountType = accountType; + } + public String getTel() { + return tel; + } + public void setTel(String tel) { + this.tel = tel; + } + +} diff --git a/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/controller/IndexController.java b/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/controller/IndexController.java new file mode 100644 index 0000000..423bdce --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/src/main/java/com/springboot/controller/IndexController.java @@ -0,0 +1,25 @@ +package com.springboot.controller; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.springboot.bean.Account; + +@Controller +public class IndexController { + + @RequestMapping("/account") + public String index(Model m) { + List list = new ArrayList(); + list.add(new Account("KangKang", "康康", "e10adc3949ba59abbe56e", "超级管理员", "17777777777")); + list.add(new Account("Mike", "麦克", "e10adc3949ba59abbe56e", "管理员", "13444444444")); + list.add(new Account("Jane","简","e10adc3949ba59abbe56e","运维人员","18666666666")); + list.add(new Account("Maria", "玛利亚", "e10adc3949ba59abbe56e", "清算人员", "19999999999")); + m.addAttribute("accountList",list); + return "account"; + } +} diff --git a/8.Spring-Boot-Thymeleaf/src/main/resources/application.properties b/8.Spring-Boot-Thymeleaf/src/main/resources/application.properties new file mode 100644 index 0000000..e0d8c46 --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.context-path=/web + +spring.thymeleaf.cache=false \ No newline at end of file diff --git a/8.Spring-Boot-Thymeleaf/src/main/resources/static/css/style.css b/8.Spring-Boot-Thymeleaf/src/main/resources/static/css/style.css new file mode 100644 index 0000000..481501b --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/src/main/resources/static/css/style.css @@ -0,0 +1,31 @@ +table { + margin: 20px 40px 20px 0px; + width: 100%; + border-collapse: collapse; + border-spacing: 0; + table-layout: automatic; + word-wrap: break-all +} +table>tbody>tr:nth-of-type(odd) { + background-color: #F7F7F7 +} + +th, td { + padding: 8px; + text-align: left; + vertical-align: middle; + font-weight: normal; + font-size: 12px; + border-bottom: 1px solid #fff; +} + +th { + padding-bottom: 10px; + color: #fff; + font-weight: 700; + background: rgba(66, 185, 131, .9) +} + +td { + border-bottom-width: 1px +} diff --git a/8.Spring-Boot-Thymeleaf/src/main/resources/templates/account.html b/8.Spring-Boot-Thymeleaf/src/main/resources/templates/account.html new file mode 100644 index 0000000..417988c --- /dev/null +++ b/8.Spring-Boot-Thymeleaf/src/main/resources/templates/account.html @@ -0,0 +1,28 @@ + + + + account + + + + + + + + + + + + + + + + + + + + + +
noaccountnamepasswordaccountTypetel
+ + \ No newline at end of file