In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2026-01-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Newcomers learn the springMVC development framework and use ajax to get the return value through @ response.
I have to say that @ response is very powerful, and it saves a lot of trouble to package the return class directly into json format.
But if the return value is of String type, there will be Chinese garbled problem. I tried to make some adjustments and checked many methods on the Internet. Sum up here.
1. Add comment produces = {"application/json;charset=UTF-8"}
@ RequestMapping (value = "/ method.do", produces = {"application/json;charset=UTF-8"})
It is suitable for a small amount, and it has to be added every time a method is written, which is not suitable for unified processing.
two。 Add configuration and configure String encoding in springMVC-*.xml, as follows
.
If you can look at the source code of the org.springframework.http.converter.StringHttpMessageConverter class, you will find that the default encoding mode is "ISO-8859-1".
This should be the main reason for our Chinese garbled code.
We have to complain here that many jar packages written by foreigners have the problem of garbled codes in Chinese. The main reason is that people don't use Chinese. Therefore, it is certain to choose "ISO-8859-1" with a small memory footprint.
When will we all be able to use utf-8?
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.