更改前端Index.html前的效果图
改写前端Index.html代码
编写IndexController
package net.tjl.blog.web;
import net.tjl.blog.service.BlogService;
import net.tjl.blog.service.TagService;
import net.tjl.blog.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class IndexController {
@Autowired
private BlogService blogService;
@Autowired
private TypeService typeService;
@Autowired
private TagService tagService;
@GetMapping("/")
public String index(@PageableDefault(size = 8, sort = {
"updateTime"}, direction = Sort.Direction.DESC) Pageable pageable,
Model model) {
model.addAttribute("page",blogService.listBlog(pageable));