2016-09-08 11 views
0

私は受け取っているPOSTに問題があります。私は次のエンドポイントがあります。誰かがこのURLに私にPOSTを送信するとき、今すぐ春のコンテンツタイプの問題

@RequestMapping(value = "/payment", method = POST) 
public void saveOrder(@RequestBody PaymentDto paymentDto) throws RequiredFieldException, IOException, MessagingException { 
//do something 
} 

を、私は応答して、次を得る:

{"errorMessage":"Unsupported Media Type", 
"errorId":"906f5dc8-0b79-4f91-9eaa-a252e8d5ac76", 
"errorDetails": 
    {"message":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported", 
    "exception":"org.springframework.web.HttpMediaTypeNotSupportedException", 
    "errors":null 
}} 

は、私はそれをどのように修正することができますか?私はそれを送信するときに私はコンテンツタイプのヘッダーを変更することはできません。それは私が制御しないサーバーから送信されます。

+0

かもしれませんこれに重複してください:http://stackoverflow.com/questions/33796218/content-type-application-x-www-form-urlencodedcharset-utf-8-not-supported-for – Minh

答えて

0

実際には、@RequestBody@ModelAttributeに変更していました。ように私のコードは、そのように見えた:コンテンツタイプは、アプリケーション/ JSONまたはアプリケーション/ xmlの使用@RequestBodyアノテーションは、ある

@RequestMapping(value = "/payment", method = POST) 
public void saveOrder(@ModelAttribute PaymentDto paymentDto) throws RequiredFieldException, IOException, MessagingException { 
//do something 
} 
0

かどうかは、アプリケーションが/ x-www-form-urlencodedで使用@ModelAttributeある場合

関連する問題