HTTP PUT であると思われるコントローラー アクションがありますが、コントローラー アクションで @RequestParam を使用しようとすると、Spring が文句を言います。HTTP PUT メソッドではリクエストパラメータが許可されていませんか?それが Spring が拒否している理由ですか?
@RequestMapping(value = "/{helpDocumentId}/vote", method = RequestMethod.PUT)
public void voteHelpfulness(@PathVariable long helpDocumentId, @RequestParam boolean isHelpful) {
helpManager.voteOnHelpDocument(helpDocumentId, isHelpful);
}
実行すると、次のエラーがスローされます。
org.springframework.web.bind.MissingServletRequestParameterException: Required boolean parameter 'isHelpful' is not present
もちろん、isHelpfulパラメータは存在します。上記のコードを HTTP POST で完全に機能させることができるので、これが問題ではないことはわかっています。
$.ajax({
url: "/help/" + helpDocumentId + "/vote.json",
type: "PUT",
data: {
isHelpful: isHelpful
},
success: function(response) {
// ....
}
});
PUT は正しい http メソッドですか? このアクションは を変更しhelpDocumentますが、作成はしません。