【问题标题】:Type The annotation @ResponsePayload is disallowed for this location类型 此位置不允许使用注释 @ResponsePayload
【发布时间】:2018-04-17 14:40:01
【问题描述】:

我已经为我的 SOAP 应用程序创建了一个端点,然后:

@ResponsePayload
public GetCountryResponse getCountry(@ResponsePayload GetCountryRequest request) {
    GetCountryResponse response = new GetCountryResponse();
    response.setCountry(countryRepository.findCountry(request.getName()));
}

getCountry 方法中的第二个@ResponsePayload 给了我这个错误:

注释@ResponsePayload 不允许用于此位置

【问题讨论】:

  • 这是一个response 注释,不应与request 一起使用

标签: spring spring-mvc spring-boot soap


【解决方案1】:

ResponsePayload 文档中,我们可以在下面找到:

表示方法返回值应该被绑定的注解 到响应负载。支持带注释的端点方法。

所以使用@RequestPayload 而不是@ResponsePayload

@ResponsePayload
public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
    GetCountryResponse response = new GetCountryResponse();
    response.setCountry(countryRepository.findCountry(request.getName()));
}

更多详情请访问ResponsePayloadRequestPayload

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-11
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多