springmvc可以直接接收表单参数或对象,使用@RequestParam或者默认不使用.
接收json的话,使用@RequestBody,可以接收对象.或者使用map接收;需要在springmvc配置文件中添加如下配置;
并且前台如果用ajax传json对象的话,注意是json对象的字符串形式,可以用JSON.stringify()进行对象转字符串;
<!--支持@RequestBody-->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
</bean>
</mvc:message-converters>
</mvc:annotation-driven>