jquery関数があり、文字列と配列の2つの型があります。文字列型のみを渡すと、コントローラーにヒットして正常に動作しますが、配列を一緒に渡すと、ネットワークエラー400の不正な要求が発生します。どうすればいいですか。コードは次のとおりです
function saveFocusGrp() {
var focusName = window.prompt('Please enter the focus group name:');
var enteredFocusList = [];
enteredFocusList = focuslist; // here focuslist is declared globally and is assigned the value in other function which I'm getting it in this function it will be in the form abc,def,xyz
alert("focus Name====>" + focusName);
alert("focus List====> " + enteredFocusList); // I get the values here in alert too
$.ajax({
url : '/DataWeb/saveFocusData',
type : 'get',
dataType : 'json',
data : { focusGroupName : focusName, focusList : enteredFocusList },
success : function(map) {
console.log(map);
var $out = $('#focusGroupName');
$out.html(map.successMsg);
}
});
}
firebug で発生するエラーは次のとおりです: NetworkError: 400 Bad Request
ホームコントローラーコード:
@RequestMapping(value = "/saveFocusData", method = RequestMethod.GET)
public void saveFocusData(HttpServletRequest req, HttpServletResponse res,
@RequestParam("focusGroupName") String focusGroupName,
@RequestParam("focusList") List focusList) throws IOException {
System.out.println("Inside home controller============");
Gson json = new Gson();
res.setContentType("application/json");
HashMap<String, String> map = new HashMap<String, String>();
String successMsg="";
map.put("successMsg", successMsg);
res.getWriter().print(json.toJson(map));
}