Spring MVC 3.2 ajax 406 修正配置
2014-08-20 00:00
337 查看
摘要: ...
MVC将自动把前台的JSON数据转换为User,自动把Map转换为JSON返回前台。
注意其中:mvc-3.2.xsd
导入 jackson-core、jackson-mapper两个jar包
Controller中
MVC将自动把前台的JSON数据转换为User,自动把Map转换为JSON返回前台
MVC将自动把前台的JSON数据转换为User,自动把Map转换为JSON返回前台。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <context:component-scan base-package="*" /> <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" /> <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name="favorPathExtension" value="false" /> <property name="favorParameter" value="false" /> <property name="ignoreAcceptHeader" value="false" /> <property name="mediaTypes"> <value> atom=application/atom+xml html=text/html json=application/json *=*/* </value> </property> </bean> ... </beans>
注意其中:mvc-3.2.xsd
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
导入 jackson-core、jackson-mapper两个jar包
Controller中
@RequestMapping(value="/checkUserName") public @ResponseBody Map<String, Object> checkUserName(@RequestBody User user){ Map<String, Object> resultMap = new HashMap<String, Object>(); return resultMap; }
MVC将自动把前台的JSON数据转换为User,自动把Map转换为JSON返回前台
相关文章推荐
- 关于springMVC 4.x配置ajax-json 出现406错误的问题。
- spring mvc ajax jsonp 跨域请求 返回值 配置
- SPRING MVC3.2案例讲解---配置
- Spring mvc使用注解@ResponseBody Ajax请求返回json报406错误
- Spring MVC ajax使用jackjson返回json报406 Not Accepatable解决办法总结
- Spring MVC 4 配置ajax请求返回json数据的问题
- Spring Mvc ajax和json数据格式的配置
- spring mvc 第二天【注解实现springmvc Handler处理ajax简单请求 的配置】
- Spring MVC前端使用ajax请求数据是报406错误
- 升级到 Spring MVC Spring framework4.1.1 导致 ajax请求 406
- Spring4 Spring MVC实战(四)——Spring MVC实现类struts通配符跳转,HMTL、Ajax和EasyUI的交互,405及406错误
- Spring mvc 下Ajax获取JSON对象问题 406错误
- Spring mvc下Ajax获取JSON对象问题 406错误
- 使用Ajax.net遇到的问题-使用会话时提示错误"只有在配置文件或 Page 指令中将启用会话状态设置为真时,才可以使用会话状态
- eclipse3.2.1+lomboz3.2安装与配置
- Eclipse3.2 Tomcat5.5.17 Oracle9配置
- Ajax基础配置 — XMLHttpRequest
- Spring MVC框架的高级配置
- Eclipse3.2+Tomcat5.5.17+Oracle9配置
- 配置一个能够编辑asp.net ajax extender的环境