関連する質問を見て、どれも役に立たなかったものを試しました。次のようにjqueryでPOSTリクエストを送信しています:
var data = {};
//this works every time and it's not issue
var statusArray = $("#status").val().split(',');
var testvalue = $("#test").val();
data.test = testvalue;
data.status = statusArray ;
$.post("<c:url value="${webappRoot}/save" />", data, function() {
})
コントローラー側では、次のことを試しました:
public void saveStatus(ModelMap model, Principal principal, HttpSession session, final HttpServletResponse response, @RequestParam String test, @RequestBody String [] status) {
//I never get to this point, but when I set statusArray to required false test variable is being populated correctly
}
public void saveStatus(ModelMap model, Principal principal, HttpSession session, final HttpServletResponse response, @RequestParam String test, @RequestParam String [] status) {
//I never get to this point, but when I set statusArray to required false test variable is being populated correctly
}
public void saveStatus(ModelMap model, Principal principal, HttpSession session, final HttpServletResponse response, @RequestParam String test, @RequestParam("status") String [] status) {
//I never get to this point, but when I set statusArray to required false test variable is being populated correctly
}
public void saveStatus(ModelMap model, Principal principal, HttpSession session, final HttpServletResponse response, @RequestParam String test, @RequestParam(name="status") String [] status) {
//I never get to this point, but when I set statusArray to required false test variable is being populated correctly
}
これらはどれもうまくいきませんでしたBad request