2017-02-12 2 views
4

Ich verwende Spring Controller, um einige Anfragen zu bearbeiten. Ich bekomme über Ausnahme. Ich habe application/json, application/xml usw. gehandhabt. Aber ich bin nicht sicher über */* und wie es im Controller behandelt werden sollte. Hier ist mein Controller-Code. HierHandhabung */* Inhaltstyp Spring Boot

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

ist die Ausnahme:

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

Bitte lassen Sie mich wissen, ich bin etwas fehlt.

Antwort

0

Dies ist die endgültige Lösung, die für mich funktionierte. Entfernt @RequestBody und hinzugefügt consumes - MediaType.All_VALUE. Hier ist der Code:

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