The vast number of webmasters have to pay attention to their own site by the search engine collection habits, recently with Baidu, 360 and other search engines, to see some of their own site, using the command "site:fansunion.cn".
I found some unusual information, more than once:
"Http://fansunion.cn/service
{"page": {"TotalCount": 5, "Totalpage": 1, "PageNo": 1, "PageSize": $, "order": null, "" ": null," params ": {}," Rows ": [{"Content": "Worship Ray for Division,...
Fansunion.cn/service 2014-11-13-Baidu Snapshot-review-translate this page
"Http://fansunion.cn/code
{"page": {"TotalCount": 7, "Totalpage": 1, "PageNo": 1, "pageSize": "," "Order": "id", "Order": "desc", "params": {}, "Rows" ": [{" Content ":" SSH framework ...
Fansunion.cn/code 2014-11-16-"
"http://fansunion.cn/code
{page: {totalcount:8, totalpage:1, Pageno:1, Pagesize:20, Orderby:id, Order:desc, params: {}, rows: [{content:, Summary: Online Demo: Little Game-Flying Pig-flappypig, updat...< BR style= "Box-sizing:border-box;" >fansunion.cn/code 2014-11-09 "
Obviously, this is data in JSON format.
However, I am a page rendered directly with Freemarker, it is impossible for me to proactively respond to JSON-formatted data.
then, it was soon thought that the project had SPRINGMVC the following configuration:
<bean class= "Org.springframework.web.servlet.view.ContentNegotiatingViewResolver" > <property name= " Defaultcontenttype "value=" Application/json "/> <property name=" mediatypes "> <map> <entry key=" html "Value=" text/html "/> <entry key=" json "value=" Application/json "/> <entry key=" xml "value=" application/x ML "/> </map> </property> <property name=" Defaultviews "> <list> <bean class=" Org.spri Ngframework.web.servlet.view.json.MappingJacksonJsonView "> </bean> <bean id=" Marshallingview "class=" O Rg.springframework.web.servlet.view.xml.MarshallingView "> <property name=" marshaller "> <bean id=" xstre Ammarshaller "class=" Org.springframework.oxm.xstream.XStreamMarshaller "> <property name=" Autodetectannotations "value=" true "/> </bean> </property> <property name=" ContentType "value= "Application/xml"/> </bean> </list> </propErty></bean>
With the above configuration, a request, a.html dynamic rendering, A.json returns JSON-formatted data.
The company project so configured, I think it is also very good, JSON format requests, as long as the request in the. JSON format, the backend does not need to manually write code.
For example, the following code:
private void list (HttpServletResponse response, list<map<string, object>> list) {Jsonobject Jsonobject = new Jsonobject (); Jsonobject.put ("list", list); Super.returnjsonobject (response, jsonobject);}
In short, the company project boss to use this configuration, the biggest goal is to easily respond to. html pages and. JSON data, even 2 of them are supported at the same time.
However, the reality confirms that this situation is likely not conducive to Baidu-360 search engine optimization.
Finally, I decided to scrap it all: Contentnegotiatingviewresolver.
If you need data in JSON format, use the Fastjson response manually.
Practice is the real truth ~
Write your own website, or very exercise people ~ a lot of questions ~
Original starting: http://fansunion.cn/article/detail/558.html
Springmvc Tai Hang One: Contentnegotiatingviewresolver may not be conducive to SEO