springMVC项目Controller中Invalid mime type错误

来源:互联网 发布:云计算iaas paas saas 编辑:程序博客网 时间:2024/06/04 18:25

在学习写SpringMVC项目的过程中,在service层里的controller里面有一个函数,需要返回json类型的数据。

于是在@RequestMapping中加入了produces参数,并添加了@ResponseBody注解。如下图所示:



但是服务器启动后,Spring会报错:

Invocation of init method failed; nested exception is org.springframework.http.InvalidMediaTypeException: Invalid mime type "application/json;charset= UTF-8":  UTF-8






定位到可能是“UTF-8”写的有问题,将大写改为小写“utf-8”就成功了。