Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
spring MVC中的媒体类型415不受支持,无法更改标头中的接受类型_Spring_Spring Mvc - Fatal编程技术网

spring MVC中的媒体类型415不受支持,无法更改标头中的接受类型

spring MVC中的媒体类型415不受支持,无法更改标头中的接受类型,spring,spring-mvc,Spring,Spring Mvc,我得到一个不受支持的媒体类型(状态代码415) 我知道为什么会发生这种情况,但我正在寻找替代解决方案。我已经看到了您更改标题的答案,但对于该客户来说,这似乎是一个难题 发件人是来自另一个公司应用程序的rest呼叫。他们没有在发送头中设置Accept:application/json。我知道这就是电话失败的原因 我知道,要想让它起作用,他们应该设置这个标题。然而,他们不愿意这样做 我的目标如下: @RestController @RequestMapping(value = "/keyconten

我得到一个不受支持的媒体类型(状态代码415)

我知道为什么会发生这种情况,但我正在寻找替代解决方案。我已经看到了您更改标题的答案,但对于该客户来说,这似乎是一个难题

发件人是来自另一个公司应用程序的rest呼叫。他们没有在发送头中设置Accept:application/json。我知道这就是电话失败的原因

我知道,要想让它起作用,他们应该设置这个标题。然而,他们不愿意这样做

我的目标如下:

@RestController
@RequestMapping(value = "/keycontentprovider")
public class KMSKeyContentProviderController {

    @Autowired
    private KeyContentProviderService keyContentProviderService;

    @RequestMapping(
            value = "/generate",
            method = RequestMethod.POST)
    public ResponseEntity<?> generateContentKey(@RequestBody final KeyGenerateRequestDTO keyGenerateRequestDTO,
                                                @RequestParam(value = "contentType", required = true) String contentType,
                                                @RequestParam(value = "streamingProtocol", required = true) String streamingProtocol,
                                                @RequestParam(value = "encryptionAlgorithm", required = true) String encryptionAlgorithm) {
        return keyContentProviderService.generateKey(keyGenerateRequestDTO.getRequest(), contentType, streamingProtocol, encryptionAlgorithm);
    }
}
@RestController
@请求映射(value=“/keycontentprovider”)
公共类KMSKeyContentProviderController{
@自动连线
私钥内容提供者服务密钥内容提供者服务;
@请求映射(
value=“/generate”,
method=RequestMethod.POST)
public ResponseEntity generateContentKey(@RequestBody final KeyGenerateRequestDTO KeyGenerateRequestDTO,
@RequestParam(value=“contentType”,required=true)字符串contentType,
@RequestParam(value=“streamingProtocol”,required=true)字符串streamingProtocol,
@RequestParam(value=“encryptionAlgorithm”,required=true)字符串encryptionAlgorithm){
返回keyContentProviderService.generateKey(KeyGenerateRequestTo.getRequest(),contentType,streamingProtocol,encryptionAlgorithm);
}
}
我曾尝试在RequestMapping定义中添加各种类型的consumes=“”,但没有成功


客户确实不想更改他们的代码(即使他们应该这样做)。无论如何,我可以绕过这个问题吗?

你可以通过过滤器在请求中添加一个标题。检查这个链接,这里是在响应中添加标题,这不是响应的答案吗?我需要为传入的请求处理它,这是为了响应..我给你这个链接是为了让你有一个想法..看看你是否可以为requestSure做类似的事情..重点是尝试创建一个过滤器来为requestAccept添加一个头与415无关。错误的接受将导致406(不可接受)。415处理内容类型(不支持的媒体类型)