在做SSM整合使用PageHelper时遇到的异常
org.springframewor k.http.converter.HttpMessageNotWritableException
No converter found for return value of type: class com.github.pagehelper.Page
错误信息:没有找到为类(class com.github.pagehelper.Page)返回的值进行转化的转化器
找了很多篇文章总结大概有一下两种提示
1、依赖包jackson没有导入,或版本问题,
导入下面依赖:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.5</version>
</dependency>
执行依旧报着同样的错误。
2、实体类中的get,set方法没有写,这个我是写了的。
最后根据提示No converter没有转化器,排查到spring-web.xml文件中在写
<mvc:annotation-driven/>
时选错了命名空间。应该选
xmlns:mvc="http://www.springframework.org/schema/mvc"
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
而选用了
xmlns:mvc="http://www.alibaba.com/schema/stat"
http://www.alibaba.com/schema/stat
http://www.alibaba.com/schema/stat.xsd
我们知道
<mvc:annotation-driven/>
是用来代替
<!-- 处理器映射器-->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<!-- 处理器适配器-->
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"/>
这两句代码。
总而言之就是粗心出的错!!!!