其他分享
首页 > 其他分享> > springmvc 入门实例,id作为形参传入,分页传入

springmvc 入门实例,id作为形参传入,分页传入

作者:互联网

 

 

@RestController
public class IndexController {

    @Autowired
    private UserService userService;

    @RequestMapping("/getone")
    public User getone(){
        User byId = this.userService.getById(1);
        return byId;

    }

    @RequestMapping("/listpage")
    public List<User> listpage(@RequestParam(value="id",defaultValue = "1") Integer pn){
        IPage page = new Page(pn,3);
        List<User> users = this.userService.page(page,null).getRecords();
        return users;

    }


    @RequestMapping("/list/{id}")
    public User list(@PathVariable Long id){
        return this.userService.getById(id);
    }

 

标签:return,RequestMapping,形参,传入,springmvc,id,User,userService,public
来源: https://www.cnblogs.com/sdgtxuyong/p/16229946.html