genon123 2021-08-30 17:21 采纳率: 100%
浏览 138
已结题

SpringBoot项目分页获取数据 java.lang.NullPointerException: null

背景:没学过前端,现在需求写个网页项目,然后突击学习了一下。测试连接数据库已经可以连接,test时数据断点也看到都是正确的,但是在尝试将数据返回前台时发生了如下错误,麻烦各位有经验的指点一下,具体错误如下:

Controller如下图:
img

运行报错:

img

后台报错截图:

img

img
2021-08-30 17:13:00.064 ERROR 11784 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

2021-08-30 17:13:00.329 ERROR 11784 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [favicon.ico], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [favicon.ico], template might not exist or might not be accessible by any of the configured Template Resolvers

Impl源码:

img

前端html代码:

img

尝试将 “ return userListService.findData(page, limit);”的 page手动赋值1000,limit赋值20:

img

重新运行后发现不报错,但是JSON数据为空:
img

vo写了个toString:

img

后台发现赋值没成功,全部为空:
img

  • 写回答

4条回答 默认 最新

  • XiaohuFight 2021-08-30 17:50
    关注

    1、对于 page,limit 手动赋值可以执行,是不是前端数据没有传到后台,输出到控制台看有没有
    2、对于数据为空,看分页查询有没有拿到数据,xml里查询语句写得是否正确或者querywrapper条件是否正确

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 9月7日
  • 已采纳回答 8月30日
  • 创建了问题 8月30日

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵