---
title: "springmvc参数传递"
author: "itgo"
date: "2014-06-17T17:10:30Z"
tags: []
categories: ["编程语言"]
slug: "springmvc"
draft: false
lastmod: "2014-06-17T17:10:30Z"
id: 2081847
url: "https://itgo.iteye.com/blog/2081847"
---

在做一个分页功能的时候，使用springmvc，使用变量currentPage代表当前页面，打开页面的时候currentPage为1，修改页面的时候用get方法修改currentPage

 

@RequestParam(value="currentPage")

 

但是，每次打开都要加个小尾巴 ：    ?currentPage=1

否则报无参数错误。

 

这时，可以设置默认值

 

@RequestParam(value="currentPage",defaultValue="1")

 

页面就可以不用加小尾巴了