2017-02-12 108 views
4

我正在使用Spring Controller來處理一些請求。我越來越例外。我已經處理了application/json,application/xml等,但我不確定*/*以及它應該如何在控制器中處理。這是我的控制器代碼。在Spring Boot中處理*/*內容類型

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

這裏是個例外:

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

請讓我知道我失去了一些東西。

回答

0

這是爲我工作的最終解決方案。刪除@RequestBody並添加consumes - MediaType.All_VALUE。這裏是代碼:

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