springboot实现API /api/{id} 后面跟直接请求的参数id

@RestController
public class UserController extends APIController{

    private static final Logger logger = LoggerFactory.getLogger(UserController .class);

    @Autowired
    @Qualifier("userService")
    private UserService userService;

    @RequestMapping(value = "/api/{id}", method = RequestMethod.GET)
    public DPInfo queryUserProcess(@PathVariable("id")int id) {
        System.out.println("aa");
        return UserService .queryUser(id);
    }

}

@RequestMapping(value = "/api/{id}@PathVariable(“id”)int id 即可。

你可能感兴趣的:(springboot)