第八章实例31,书本207页中在Mapper中直接返回page对象时的控制类UserListControllerB中getUserList方法的参数没有指定默认值,项目运行时会报错。如果改成public Page<User> getUserList(@RequestParam(value=”pageNum”,defaultValue=”0”)int pageNum, @RequestParam(value = “pageSize”, defaultValue = “5”) int pageSize)运行就正常了。
非常感谢您,这是更严谨的写法,已经补充到源码中,谢谢您。 地址见: https://github.com/xiuhuai/Spring-Boot-Book/commit/9ffcad57894dddfab6c4f2eaf8ebd507e1a73733
第八章实例27 , 实例没有配置数据库.先创建数据库book, 然后在application.properties中添加创建和更新数据表配置spring.jpa.hibernate.ddl-auto=update
非常感谢您提交的问题,回答如下: 因为是进阶章节,所以不能重复编写。关于配置数据库的问题,请参考前面的“8.2.3 使用JPA”,里面有配置数据库的讲解。
第五章 th:errors=”{answer}” 这个和{answer} 组合起来是什么意思?
非常感谢您的反馈,回答如下: 源码:th:if="${#fields.hasErrors('answer')}" th:errors="*{answer}" 解释:前面th:if表达式是判断填写的字段answer否有错,th:errors表达式可以取得错误信息的内容,即决定提示什么错误信息,建议多次在表单中填写不同的值来获取反馈,以便理解。
第八章实例31,书本207页中在Mapper中直接返回page对象时的控制类UserListControllerB中getUserList方法的参数没有指定默认值,项目运行时会报错。
如果改成public Page<User> getUserList(@RequestParam(value=”pageNum”,defaultValue=”0”)int pageNum, @RequestParam(value = “pageSize”, defaultValue = “5”) int pageSize)运行就正常了。
第八章实例27 , 实例没有配置数据库.
先创建数据库book, 然后在application.properties中添加创建和更新数据表配置
spring.jpa.hibernate.ddl-auto=update
第五章 th:errors=”{answer}” 这个和{answer} 组合起来是什么意思?