StringMVC @RequestParam属性
1、jsp:
<a href="springmvc/testRequestParam?username=allen&age=sss">test RequsetParam</a>
<br/><br/>
2、Controller:
@RequestMapping(value="/testRequestParam")
public String testRequestParam(@RequestParam(value="username") String un,
@RequestParam(value="age",required=false,defaultValue="0") int age){
System.out.println("testRequestParam username: " + un + ",age: " + age);
return SUCCESS;
}
value 值即请求参数的参数名
required 该参数是否必须,默认为true
defaultValue 请求参数的默认值,指定是为了防止参数为空时,类型不一致导致报错