1.2 Analysis
1 Create a user database table
2 persistence framework spring data jpa
3 json jsp static html freemarker
1.3 page display
HTML display data vue.js angular.js
Dynamic page shows: Each page request is generated once
Jsp servlet essentially works on a web project -
springbooot project does not recommend the use of jsp
Template technology freemarker
tymeleaf
velocity
Steps for usage:
a: add dependencies
b: Create a template file location to save resources / templates directory under the file extension .ftl
c write controller sends the result back to the template
1.4 yaml file format
key --value
1.4.1 Syntax key: value
key1:
key2:
key3: value
1.4.2 property values from
<html> <head> <title> spring boot</title> </head> <body> <table border="3px"> <thead> <tr> <th>id</th> <th>账号</th> <th>密码</th> <th></Nameth> </tr> </thead> <#list userList as user > <!--userList为controller中添加到域对象中的数据--> <tbody> <tr> <td>${user.id}</td> <td>${user.username}</td> <td>${user.password}</td> <td>${user.name}</td> </tr> </tbody> </#list> </table> </body> </html>
Creating Controller Interface
package com.xhn.controller; import com.xhn.dao.UserDao; import com.xhn.entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; @Controller @RequestMapping("/page") public class PageUserController { @Autowired private UserDao userDao; //查询数据库数据 @RequestMapping("/user/list") Public String getUserList (a ModelMap Map) { List <the User> userList = userDao.findAll (); map.addAttribute ( "userList" , userList); return "User" ; // view similar to the internal resolver springmvc in front suffixes do not write } }
UserDao layer:
https://www.cnblogs.com/xinghaonan/p/11799854.html
The day before write notes, will not be repeated
carry out