spring配置错误Could not find acceptable representation
来源:互联网 发布:免费售楼软件 编辑:程序博客网 时间:2024/05/01 01:02
pring 报错,Could not find acceptable representation
使用spring mvc框架我们可以可以使用@ResponseBody注解,相应ajax请求并返回一个对象,如我们自定义的对象,或者一个List,但这需要我们在spring的配置文件中进行配置:
否则回报:org.springframework.web.HttpMediaTypeNotAcceptableException:Could not find acceptable representation 错误
下面是配置代码:
<!--处理 @ResponseBody 中文乱码问题--><bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"><property name="messageConverters"><list><bean class="org.springframework.http.converter.StringHttpMessageConverter"><property name="supportedMediaTypes"><list><value>text/html;charset=UTF-8</value></list></property></bean><span style="color:#ff0000;background-color: #ffffff;"><!-- 启动JSON格式的配置 --><bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"><!-- 解决 HttpMediaTypeNotAcceptableException: Could not find acceptable representation --><property name="supportedMediaTypes"><list><value><span style="background-color: #99ccff;">application/json;charset=UTF-8</span></value></list></property></bean></span></list></property></bean>
另外我们还需要注意对用到的jar进行引用,如果报 java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonGenerationException
错误应该是缺少jackson相关的jar
0 0
- spring配置错误Could not find acceptable representation
- http错误:Could not find acceptable representation
- Could not find acceptable representation
- Could not find acceptable representation
- Could not find acceptable representation
- Spring Boot: HttpMediaTypeNotAcceptableException: Could not find acceptable representation原因及解决方法
- Springmvc 406 状态码 / Could not find acceptable representation
- HttpMediaTypeNotAcceptableException: Could not find acceptable representation原因及解决方法
- org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio
- org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio
- org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio
- org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio
- Could not find *.apk 错误
- 使用spring的@ResponseBody注解报Not Acceptable错误
- could not find object错误的解决办法
- Android出现Could not find ***.apk!错误
- CMake 运行错误 could not find CMAKE_ROOT
- 关于 Could not find main class 错误
- 如何在项目启动的时候做一些业务处理 (实现ServletContextListener)
- HTML5 - 用<figure/>添加插图和图题
- 关于IE中image的onload事件失效解决问题
- UFUN学习板的测试与学习
- 数据库事务的特点与隔离级别
- spring配置错误Could not find acceptable representation
- Fragment生命周期
- iOS-UIStackView的演练
- Linux开启FTP共享操作
- 学习工具、教程 推荐
- 读取java项目下的文件
- Android--Demo_PullToRefresh(特效篇)
- 解决Xamarin Android SDK Manager闪退问题
- h_errno