I have tried the following line in my ajax call as it was suggested all over internet:
contentType: "application/json; charset=ISO-8859-1"
but it did not change anything. Whenever I make a call from ajax with a string parameter which has an accent for example società, at my controller(I'm using Java, spring framework), i receive it as SocietÃ. I have tried first UTF-8 which is the default (as far as I know) but nothing. Here is my full function:
function foo(customer, society) {
$.ajax({
url: 'notMappedAcoStaffing.do',
type: "GET",
contentType: "application/json; charset=ISO-8859-1",
data: { customer: customer, society: society},
success: function(data) { $('#content').html(data); },
error: function(error) { alert("error" + error); }
});
}
And I take the values on my backend as
@RequestMapping(method = RequestMethod.GET)
public ModelAndView fooController(@RequestParam("customer") final String customerParam, @RequestParam(value="society",required=false) Integer societyParam) {...}
Is there a way to resolve this issue? Thanks for your help in advance.
UPDATE: I have still no idea why I receive it distorted as parameter at my controller. But however when I convert it as follows: How do I convert between ISO-8859-1 and UTF-8 in Java? ,it comes out all good. Seeing that it works, I tried it again to set UTF-8 in my ajax call but no success... It resolved my issue but honestly I do not like this way. Please share with me if you have a better solution maybe on the ajax call side. Thanks