使用backbone 模型的save方法,发送post请求
model.save(model.toJSON())
无法解析json注入对象,代码如下:
@RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers ={"Accept=application/json"})
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
public String add(@RequestBody Activity activity, HttpServletRequest request, HttpServletResponse response) {
另外还配置了jakson,也不好用,代码如下:
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="atom" value="application/atom+xml"/>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
</list>
</property>
</bean>
Answer it yourself, the problem has been solved.
spring mvc does not need to modify any configuration, the backbone version used is 1.0.0
Modify backbone emulateJSON = true
Same request! ! ! Waiting online! ! !
I previously encountered a request submitted by angular that the background php could not parse, mainly because the sent and received types did not match
Link: angularjs transfers parameters to the background, but the background cannot receive data
I can only help here, give the poster an idea, and give me a thumbs up
Write a filter and intercept it in front of spring mvc. Look at the content in requst to see if you find anything