500 (Internal Server Error)

1,043 阅读1分钟

今天写Ajax请求然后在服务端出现500 (Internal Server Error)这个错误,在浏览器上也没有找到错误提示,但是经过不断百度,终于找到了

1.首先。用谷歌浏览器,点击请求,然后F12,找到后台控制器

然后在根据提示解决问题

 No converter found for return value of type: class java.util.ArrayList  这个错误大概意思就是找不到类型转换的返回值,就是数据类型转换错误

这个问题解决,

1.数据类型转换成json类型时,要在pom.xml文件中手动添加Jackson依赖

<!--jackson依赖-->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.11.0</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.11.0</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.11.0</version>
    </dependency>

添加依赖之后记得重启maven

2.有些人可能加了依赖之后还是出现同样的错误,这是你检查你自己的注解驱动器有没有选错

<mvc:annotation-driven/>

这个敲出来会有很多不同的路径

选择正确之后,就不会再报500了