广大站长都有关注自己网站被搜索引擎收录的习惯,最近用百度、360等搜索引擎,查看了自己网站的一些情况,使用命令“site:fansunion.cn”。
我发现了一些异常信息,不止一次:
“http://fansunion.cn/service
{"page":{"totalCount":5,"totalPage":1,"pageNo":1,"pageSize":10,"orderBy":null,"order":null,"params":{},"rows":[{"content":" 拜小雷为师,...
fansunion.cn/service 2014-11-13 - 百度快照 - 评价 - 翻译此页”
“http://fansunion.cn/code
{"page":{"totalCount":7,"totalPage":1,"pageNo":1,"pageSize":10,"orderBy":"id","order":"desc","params":{},"rows":[{"content":" SSH框架...
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 : 在线演示:小游戏-会飞的猪-FlappyPig , updat...
fansunion.cn/code 2014-11-09”
很明显,这是JSON格式的数据。
但是,我是用Freemarker直接渲染的页面,不可能是我主动响应JSON格式的数据。
于是,很快联想到,项目中有SpringMVC如下配置:
<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/xml" />
</map>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
</bean>
<bean id="marshallingView"
class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="marshaller">
<bean id="xStreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="autodetectAnnotations" value="true" />
</bean>
</property>
<property name="contentType" value="application/xml" />
</bean>
</list>
</property>
</bean>private void list(HttpServletResponse response,
List<Map<String, Object>> list) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", list);
super.returnJsonObject(response, jsonObject);
}原文首发:http://fansunion.cn/article/detail/558.html
SpringMVC大坑一枚:ContentNegotiatingViewResolver可能不利于SEO
原文地址:http://blog.csdn.net/fansunion/article/details/41877255