0

I want to send parameter in variable mois :"Février" , the problem is when i sent the parameter which it contain accent like é , i get other value in class java by @ResponseBody: Février my url is : http://othman-pc.com:8080/COSUMAR_WebAdmin/moisTest.html?mois=Février

the probléme is thas in console java : System.out.println("Mois :"+ mois);

i Get :

Mois :Février

Getjson :

$.getJSON("moisTest.html", {mois: $(this).val()}, function(j) { if (j === false) { alert("good")     });

Spring @ResponseBody

@RequestMapping(value = "/moisTest.html",method = RequestMethod.GET)
  public @ResponseBody String moisTest(@RequestParam(value ="mois") String mois){
             System.out.println("Mois :"+ mois);

            return "false";}

my JSP :

<%@ page  contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 

Headers statue:

Request URL:http://localhost:8080/COSUMAR_WebAdmin/moisTest.html?mois=F%C3%A9vrier
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,ar;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=zMFHDOspJtUYA+Eg4hidb+C1.undefined; ASP.NET_SessionId=ohyxckjs40vkg121wnnvygwn; fcspersistslider2=1; submenuheader=0c; PHPSESSID=vak58e1nha6mg51prp4ke0l3f3; JSESSIONID=29a2a59a435d5e9fe335568f602d; treeForm_tree-hi=treeForm:tree:resources:JDBC:connectionPoolResources:evpsPool
Host:localhost:8080
Referer:http://localhost:8080/COSUMAR_WebAdmin/upload.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
X-Requested-With:XMLHttpRequest
Query String Parametersview sourceview URL encoded
mois:Février
Response Headersview source
Cache-Control:no-cache
Cache-Control:no-store
Content-Length:5
Content-Type:application/json
Date:Sat, 01 Mar 2014 15:08:05 GMT
Expires:Thu, 01 Jan 1970 00:00:00 GMT
Pragma:no-cache
Server:Apache-Coyote/1.1    
user2912015
  • 9
  • 1
  • 5

1 Answers1

2

It is common problem for applications running on tomcat. To solve this open server.xml tomcat configuration, find <Connector> tag with your port (e.g. 8080) and add following: URIEncoding="UTF-8"

Server configuration can be found in or server folder or in "Servers" folder in project explorer (if you use eclipse)

server.xml location

yname
  • 2,189
  • 13
  • 23
  • thanks you so much for your response but i am using Jboos 7.1.1 i cant found server.xml it not same confuguration with jboos 7 in file standalone.xml. can you help me pleaze – user2912015 Mar 02 '14 at 15:03
  • Sorry, I didn't work with JBoss. Try to search "Jboss connector utf-8" (maybe this will help you: http://stackoverflow.com/questions/10226018/jboss-encoding-utf-8) – yname Mar 02 '14 at 20:10
  • thank you soooooooooooooooooooooo muchhhhhhhhhhhhhhhhhhhhhhhhhhh i resolve my probleme i change jboos with tomcat and adding config in server.xml i i succeed to get good caracetere with accent thanks youuuuuuuuuuuuuuu – user2912015 Mar 07 '14 at 01:46
  • Hi! Thanks for suggestion @TheUser518469 it solves my problem also ... But could you explain to us this solution. I mean why customizing the standalone.xml of jboss (or server.xml of tomcat) is the solution for this issue. I'm working on an existing project and modifying the server could "eventually" cause some problems... thanks – javaxiss Sep 24 '14 at 15:02
  • Hi, javaxiss. I believe this problem is not related to your code, but it is related to server configuration. What webserver is? It is a program that listens to incoming requests and transfers it to your software. It is like an switchboard-operator (http://en.wikipedia.org/wiki/Switchboard_operator): you pick up a phone, say: "I want to talk with " and switchboard operator connects you with requested person. But if operator understands only English and you talking in Russian in can cause some problems. In that case you should specify: "Please give me russian-speaking operator". – yname Sep 25 '14 at 03:59