今天写了一个挺好玩的小程序java回收站(主要是通过一个字段练判断我们数据的状态) 代码如下
1.实体类
package com.bwie.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.regex.PatternSyntaxException;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "boke")
public class Boke {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;//id
private String name;//标题
private String nei;//内容
}
2.控制层
package com.bwie.controller;
import com.bwie.pojo.Boke;
import com.bwie.service.BokeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/boke")
public class BokeController {
@Autowired
private BokeService bokeService;
//正常列表
@RequestMapping("/list")
public String list(Model model){
List<Boke> list=bokeService.list();