I instruct my URL to send an Ajax request like that:
url += '/' + something + '/' + id;
var response;
$.ajax({
async : false,
type: 'DELETE',
url: url,
...
My removeId
is a variable that includes UTF-8 character. I will handle that variable at Java side like that:
@RequestMapping(value = "/something/{id}", method = RequestMethod.DELETE)
public void myMethod(HttpServletResponse response, @PathVariable String id) {
...
However id
variable at Java side is different from its original because UTF-8 characters changes to strange things.
How can I send UTF-8 characters from JavaScript side and transform it again at my Java side (Spring 3 with REST, my web server is Tomcat 7)?
PS 1: Even I don't use encodeUriComponent
it seems that my URL is encoding by itself?
PS 2: To make question more clear:
i.e. my id variable is ara? and sent URL is: localhost:8080/sdfasf/ara%C3%A7
When I see that id variable has that value:
ara?§
instead of:
ara%C3%A7
Does Spring (or Tomcat) automatically do it? Is there any way to decode it automatically when it comes to controller as a path variable (I mean without writing anything as like:
URLDecoder.decode(id,"UTF-8");
it will be converted automatically)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…