Processing * / * content in Spring Download

I am using a Spring controller to handle some requests. I get an exception. I processed application/json, application/xmletc. But I'm not sure about */*how it should be handled in the controller. Here is my controller code.

@RequestMapping(value = "/handle", method = RequestMethod.POST)
    public @ResponseBody Response handleRequest(HttpServletRequest request, @RequestBody TestDTO testDTO, HttpServletResponse httpServletResponse) throws Exception {
}

Here is the exception:

Unexpected error: Content type '*/*;charset=UTF-8' not supported
org.springframework.web.HttpMediaTypeNotSupportedException: Content type '*/*;charset=UTF-8' not supported

Please let me know that I am missing something.

+4
source share
1 answer

This is the final solution that worked for me. Deleted @RequestBodyand added consumes- MediaType.All_VALUE. Here is the code:

@RequestMapping(value = "/notify", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
    public @ResponseBody Response notifyPaymentPost(HttpServletRequest request, PaymentDTO paymentDTO, HttpServletResponse httpServletResponse) throws Exception {
}
0
source

Source: https://habr.com/ru/post/1669514/


All Articles