当时遇到的问题是:
使用的是百度地图逆地址解析api,在控制器上面返回的结果是正确的
返回的结果如下:
{“status”:0,“result”:{“location”:{“lng”:99.63056209767264,“lat”:36.77213052355966},“formatted_address”:“青海省海南藏族自治州共和县”,“business”:"",“addressComponent”:{“country”:“中国”,“country_code”:0,“country_code_iso”:“CHN”,“country_code_iso2”:“CN”,“province”:“青海省”,“city”:“海南藏族自治州”,“city_level”:2,“district”:“共和县”,“town”:"",“adcode”:“632521”,“street”:"",“street_number”:"",“direction”:"",“distance”:""},“pois”:[],“roads”:[],“poiRegions”:[],“sematic_description”:"",“cityCode”:68}}
但是到了浏览器之后就成了这样子了
“{“status”:0,“result”:{“location”:{“lng”:99.63056209767264,“lat”:36.77213052355966},“formatted_address”:”???",“business”:"",“addressComponent”:{“country”:"??",“country_code”:0,“country_code_iso”:“CHN”,“country_code_iso2”:“CN”,“province”:"???",“city”:"???",“city_level”:2,“district”:"???",“town”:"",“adcode”:“632521”,“street”:"",“street_number”:"",“direction”:"",“distance”:""},“pois”:[],“roads”:[],“poiRegions”:[],“sematic_description”:"",“cityCode”:68}}"
解决方法:
1、首先要在spring-mvc.xml处加上一段代码
代码如下:
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
2、再在后端@RequestMapping处加上,produces = “text/plain;charset=utf-8” 即可
ok