I am working with Spring and trying to make an ajax call to @ResponseBody in my controller.
UPDATE
Ok, I added the changes that were told to me in my ajax settings. My parameter "jtSearchParam" still has the same encoding issue in IE. + I got another error, 406, the response header has the wrong content type.
Here is my new code
Controller:
@RequestMapping(method = RequestMethod.POST, consumes="application/json; charset=utf-8", produces="application/json; charset=utf-8")
public @ResponseBody JSONObject getUsers(@RequestParam int jtStartIndex, @RequestParam int jtPageSize,
@RequestParam String jtSorting, @RequestParam String jtSearchParam,
HttpServletRequest request, HttpServletResponse response) throws JSONException{
Gson gson = new GsonBuilder()
.setExclusionStrategies(new UserExclusionStrategy())
.create();
List<User> users = userService.findUsers(jtStartIndex ,jtPageSize, jtSorting, jtSearchParam);
Type userListType = new TypeToken<List<User>>() {}.getType();
String usersJsonString = gson.toJson(users, userListType);
int totalRecordCount = userDao.getAmountOfRows(jtSearchParam);
usersJsonString = "{\"Message\":null,\"Result\":\"OK\",\"Records\":" + usersJsonString + ",\"TotalRecordCount\":" + totalRecordCount + "}";
JSONObject usersJsonObject = new JSONObject(usersJsonString);
return usersJsonObject;
}
So, as you can see, I set the content type to produces, but that doesn't help. If I debug the response header, it looks like this: (This makes it impossible to use 406 from the browser)

And my new ajax settings:
...
headers: {
Accept : "application/json; charset=utf-8",
"Content-Type": "application/json; charset=utf-8"
},
contentType: "application/json; charset=utf-8",
mimeType:"application/json; charset=UTF-8",
cache:false,
type: 'POST',
dataType: 'json'
...
And my options still look the same in IE!
