I run a Java Spring project. For dev purposes, I have an embedded Tomcat in my Eclipse in order to test my development continuously.
I deployed the spring boot app on a VPS where Tomcat 9 is running, and on the VPS I encounter encoding issues when I get a JSON file.
On the VPS if I type in the terminal root@vps:~# curl --cookie "lang=fr" localhost:8080/utils
I get
{signout: "Se déconnecter"}
On my computer, with Firefox if I type in the address bar localhost:8080/utils
(it targets tomcat embedded in Eclipse), I get
{signout: "Se déconnecter"}
But on my computer, with the same Firefox if I type in the address bar my.vps.ip:8080/utils
I get
{signout: "Se déconnecter"}
The controller function is
@RequestMapping("/utils")
public String getUtils(@CookieValue(defaultValue = "en", value = "lang", required = false) String languageCode) {
if (!languageService.exists(languageCode)) {
languageCode = "en";
}
return String.format("/msg/%s/displayedWords.js", languageCode);
}
I tried to add URIEncoding="UTF-8"
to the Connector
definition on Tomcat file /etc/tomcat/server.xml
but nothing changed.
What could be wrong? Thanks
EDIT
The locale on the VPS:
root@vps:~# locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC=C.UTF-8
LC_TIME=C.UTF-8
LC_COLLATE="C.UTF-8"
LC_MONETARY=C.UTF-8
LC_MESSAGES="C.UTF-8"
LC_PAPER=C.UTF-8
LC_NAME=C.UTF-8
LC_ADDRESS=C.UTF-8
LC_TELEPHONE=C.UTF-8
LC_MEASUREMENT=C.UTF-8
LC_IDENTIFICATION=C.UTF-8
LC_ALL=