I have an application that is based on mongodb + spring and a RESTful interface (via Spring MVC).
When we send a request to the server to make an update (e.g. a user field), and the field has non-ascii character (e.g. Cyrillic / Russian) it is saved to mongo but when we read it back through the interface we get garbled chars.
Any ideas on how to tackle this issue?
Thanks!
We have found out that the issue was with how JSoup treats non-ascii chars. Now it works.
Related
I add some custom attributes which contains Chinese in a Spring Boot project. However, the attributes show the wrong way.
I use the idea and set file encoding with utf-8.
Oh, and I am using YAML instead of Properties
What should I do?
oh, there is no problem.I use the Properties file before, and change to YAML.
So, it shows wrong situation.
I solve the problem by cleaning the project and restarting it.
i am new to spring and i have developed an application using spring mvc. i have created controllers which use request mapping annotations to handle mapping between jsp to controller (for example; a controller named Driver have several mappings like /drivers/update/{id}, /drivers/edit/{id} etc.). but when i use /drivers/update/{id} mapping and i want to use /drivers/edit/{id} mapping at very next call, the URL changes to "myproject/drivers/update/any_id/drivers/edit/any_id" in the URL of browser.
I think it's spring mapping handler concept related problem, but i don't know what it is actually. Please don't ask the code to be uploaded because i don't have code now. Please help(i am sure someone have already faced the problem)
I guess the URI pattern you are using is not correctly written. Prepend a forward slash / in the URI pattern.
For example:
#requestMapping("/yoururl") - correct.
#requestMapping("yoururl") - incorrect.
Note: without / it will keep appending the URL. I tried this way and it was solved in my case.
I recently upgraded Tomcat from v7.0.26 to v7.0.76 for one of my webapp. The URLs that were working earlier are not getting encoded. : gets encoded as %3A. I tried mentioning UTF-8 in the web.xml and server.xml, but the encoding is still seen. Has anyone come across a similar issue?
After investigating the tomcat changelog and trying several versions of tomcat, found that tomcat v7.0.70 has a change for this issue. The changeset is here. This change causes the URL to be encoded when you do a getRequestURI() call.
To avoid this issue of encoding, we are using Tomcat version prior to 7.0.70.
Alternatively there is a flag dispatchersUseEncodedPaths which can be used to enable/disable this encoding that was introduced in tomcat v7.0.70.
I use #ConfigurationProperties to customize my own properties in application.properties.
But when I use chinese in application.properties, I found out Spring Boot load application.properties file in ISO-8859-1 encode. How do I customize this defalut encoding using UTF-8.
JAVA hold all string in memory with unicode instead of its own encoding. So the importance is to tell java how to load string in correct encoding. Most common solution (i18n use this way) is to translate chinese into unicode, which java can handle it directly.
Here is an online tool to translate chinese to unicode. Hope this helps.
Try to move your definition into src/main/resources/messages_zh_CN.properties. (messages_zh_CN.properties is utf8)
I want to convert my web application into Gujarati language.In my web application i use Spring and Hibernate framework.how can i do this ? Please give me solution.
One solution can be using ReloadableResourceBundleMessagesource.
As for example, if you want the site in two different languages, say english and german, then create two different properties file, messages_de and messages_en.
Use a LocaleResolver to resolve the Locale and LocaleChangeInterceptor to intercept the request and set the lang value.
Follow this simple example :
http://viralpatel.net/blogs/spring-3-mvc-internationalization-i18n-localization-tutorial-example/
I will look into the possibilities of using some translation API and let you know if I get something.