【发布时间】:2014-05-02 15:42:34
【问题描述】:
您好,我正在使用 Spring MVC。在我的控制器中,我期待表单数据
@RequestMapping(value = "/get/data/grid", method = RequestMethod.POST)
public ModelAndView getData(@RequestBody DataGrid dataGrid) { }
但是我收到了这个HttpMediaTypeNotSupportedException: Content type 'application/json' not supported 错误。我很好奇这可能是因为我的 formbean 对象中的 HsshMap DataGrid 这就是这个对象的样子:
public class DataGrid implements Serializable{
/**
*
*/
private static final long serialVersionUID = 5979434283059930104L;
private String transactionAction;
private String transactionDate;
private List<GridColumn> columns;
private List<Map<GridColumnName,Object>> rows;
public Grid(){
this.columns = new ArrayList<GridColumn>();
this.rows = new ArrayList<Map<GridColumnName,Object>>();
}
...getter setter here
【问题讨论】:
-
你的类路径中有 Jackson 吗? MappingJackson(2)HttpMessageConverter 可能因此未注册。
-
如果你有 Jackson,哪个版本?
标签: spring-mvc jackson