简单参数接收
1. 根据id查询数据:
- 请求路径:
http://localhost:8080/findUserById?id=1
- 控制层UserController
package com.jt.controller;
import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class UserController {
@Autowired
private UserService userService;
@GetMapping("findUserById")
public User findUserById(Integer id){
return userService.findUserById(id);
}
}
package com.jt.service