springboot+mybatis+thymeleaf增删改查demo

依赖添加参考

参考文档

entity

package per.jarping.blog.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;

public class BlogTag {
    private Integer tagId;

    private String tagName;

    private Byte isDeleted;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    public Integer getTagId() {
        return tagId;
    }

    public void setTagId(Integer tagId) {
        this.tagId = tagId;
    }

    public String getTagName() {
        return tagName;
    }

    public void setTagName(String tagName) {
        this.tagName = tagName == null ? null : tagName.trim();
    }

    public Byte getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Byte isDeleted) {
        this.isDeleted = isDeleted;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", tagId=").append(tagId);
        sb.append(", tagName=").append(tagName);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", createTime=").append(createTime);
        sb.append("]");
        return sb.toString();
    }
}

修改mapper,service,impl




    
        
        
        
        
    
    
        
        
        
    
    
    tag_id, tag_name, is_deleted, create_time
  

   

    


public interface TagService {
    List listTags();
}
package per.jarping.blog.service.impl;

import per.jarping.blog.dao.BlogTagMapper;
import per.jarping.blog.dao.BlogTagRelationMapper;
import per.jarping.blog.entity.BlogTag;
import per.jarping.blog.entity.BlogTagCount;
import per.jarping.blog.service.TagService;
import per.jarping.blog.util.PageQueryUtil;
import per.jarping.blog.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class TagServiceImpl implements TagService {

    @Autowired
    private BlogTagMapper blogTagMapper;
    
    @Override
    public List listTags() {
        return blogTagMapper.listTags();
    }
}

编写controller

@Controller
@RequestMapping("/admin")
public class BlogController {

    @Resource
    private TagService tagService;

    @GetMapping("/blogs/edit")
    public String edit(HttpServletRequest request) {
        request.setAttribute("tags",tagService.listTags());
        return "admin/edit";
    }
}

修改edit.html



发布文章

  

-----------------------------------------修改------------


-----------------------------------------修改------------


                            
  
     

效果
springboot+mybatis+thymeleaf增删改查demo_第1张图片

这是入门级别的查询列表,thymeleaf交互


广告。。。

博主个人博客http://blog.jathamcloud.top

你可能感兴趣的:(springboot+mybatis+thymeleaf增删改查demo)