[英]EnumType @RequestParam not working on spring
所以伙计们,我不知道发生了什么,我需要向 db 表添加一个条目。 我创建了一个端点,它需要一个名为 ActionStatisticType 的 EnumType 作为参数,但 Spring 无法映射它。
这是我在 angular 中执行请求的方式:
this.httpService.put(this.serviceUrl, actionType)
这是它向后端创建的请求:
这就是我在 spring 上映射它的方式:
@RequestMapping(method = RequestMethod.PUT)
public void create(@RequestParam ActionStatisticType actionType) {
log.info("#ActionStatisticController.register {}", actionType);
this.service.create(actionType);
}
这是我得到的错误:
org.springframework.web.bind.MissingServletRequestParameterException: Required ActionStatisticType parameter 'actionType' is not present
我也尝试将它封装在一个对象中并设置一个属性名称,但它也不起作用。
你能告诉我我做错了什么吗? 谢谢你。
首先,您需要提供参数的名称:
@RequestParam(value = "actionType") ActionStatisticType actionType
之后,您需要尝试使用参数调用 URL,请参见以下示例:
https://localhost:8773/webfront/actions?actionType=TEST_ACTION_TYPE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.