2 回答
TA贡献1801条经验 获得超16个赞
@RequestMapping(value = "userRight/hasRightForOperation", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> hasRightForOperation(@PathVariable(value = "loginName") String loginName,
@PathVariable(value = "vendorId") String vendorId,
@PathVariable(value = "accessRightCode") String accessRightCode) {
return new ResponseEntity<>(hasRightForOperation(loginName, vendorId, accessRightCode), HttpStatus.OK);
您正在使用 @PathVariable 但您的 url 映射没有参数。你可以修复像
@RequestMapping(value = "userRight/hasRightForOperation/{loginName}/{vendorId}/{accessRightCode}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> hasRightForOperation(@PathVariable(value = "loginName") String loginName,
@PathVariable(value = "vendorId") String vendorId,
@PathVariable(value = "accessRightCode") String accessRightCode) {
return new ResponseEntity<>(hasRightForOperation(loginName, vendorId, accessRightCode), HttpStatus.OK);
您可以更改 url 映射参数的顺序。因此,如果您不想使用 url 映射,则可以使用 @RequestParam 标签获取参数。
@GetMapping(value = "userRight/hasRightForOperation", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> hasRightForOperation(@RequestParam("loginName") String loginName,
@RequestParam("vendorId") String vendorId,
@RequestParam("accessRightCode") String accessRightCode) {
return new ResponseEntity<>(hasRightForOperation(loginName, vendorId, accessRightCode), HttpStatus.OK);
}
TA贡献1847条经验 获得超11个赞
您必须在 URL 中接收路径变量,以便添加如下所有参数。
改变
@RequestMapping(value = "userRight/hasRightForOperation", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
到
@RequestMapping(value = "userRight/hasRightForOperation/{loginName}/{vendorId}/{accessRightCode}", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
我会推荐你使用@RequestParam
这个。
添加回答
举报