gpt4 book ai didi

rest - 嵌套 Rest 资源在 Jhipster 中引发约束违规

转载 作者:行者123 更新时间:2023-12-05 00:46:10 24 4
gpt4 key购买 nike

我有一个这样的嵌套资源:

@GetMapping("/tour-requests/{tourRequestId}/tour-request-messages")
@Secured({AuthoritiesConstants.ADMIN})

public ResponseEntity<List<TourRequestMessageDTO>> getTourRequestMessagesForTourRequest(
@PathVariable("tourRequestId") long tourRequestId,
TourRequestMessageCriteria criteria) {
...
}

当我调用此资源时,例如使用 GET api/tour-requests/1301/tour-request-messages我收到意外错误:
{
"type": "https://zalando.github.io/problem/constraint-violation",
"title": "Constraint Violation",
"status": 400,
"path": "/api/tour-requests/1301/tour-request-messages",
"violations": [
{
"field": "tourRequestId",
"message": "Failed to convert property value of type 'java.lang.String' to required type 'io.github.jhipster.service.filter.LongFilter' for property 'tourRequestId'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'io.github.jhipster.service.filter.LongFilter' for property 'tourRequestId': no matching editors or conversion strategy found"
}
],
"message": "error.validation"
}

我试图调试这个,似乎在调用方法之前发生了异常-

最佳答案

问题是搜索条件劫持了路径参数tourRequestId ,因为它恰好也是生成的 QueryService 的一个可能的搜索参数。
这就是为什么它试图转换 tourRequestId LongFilter 的参数.

将路径变量重命名为 ìd` 也没有帮助,但在将其重命名为不同的名称后,问题就消失了。

关于rest - 嵌套 Rest 资源在 Jhipster 中引发约束违规,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49190755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com