在做一个分页功能的时候,使用springmvc,使用变量currentPage代表当前页面,打开页面的时候currentPage为1,修改页面的时候用get方法修改currentPage
@RequestParam(value="currentPage")
但是,每次打开都要加个小尾巴 : ?currentPage=1
否则报无参数错误。
这时,可以设置默认值
@RequestParam(value="currentPage",defaultValue="1")
页面就可以不用加小尾巴了
本文介绍在使用SpringMVC实现分页功能时,如何设置请求参数的默认值来简化URL。通过使用@RequestParam注解及其defaultValue属性,可以避免在URL中每次都必须指定当前页面编号。
在做一个分页功能的时候,使用springmvc,使用变量currentPage代表当前页面,打开页面的时候currentPage为1,修改页面的时候用get方法修改currentPage
@RequestParam(value="currentPage")
但是,每次打开都要加个小尾巴 : ?currentPage=1
否则报无参数错误。
这时,可以设置默认值
@RequestParam(value="currentPage",defaultValue="1")
页面就可以不用加小尾巴了
1313
287

被折叠的 条评论
为什么被折叠?