比如有如下的Action方法:
@RequestMapping("/test/{p1}/{p2}")
public String testRest(@RequestParam String p1, @RequestParam String p2){
System.out.println("p1:"+p1);
System.out.println("p1:"+p1);
return "/jsp/test";
}
那么当访问的URL为:
http://localhost:8080/test/param1/param2
时会正常打印出
1:param1
p2:param2
但是当访问地址为
http://localhost:8080/test/
时就直接报错了,怎样才能实现访问这个url时自动给p1和p2一个默认值呢?
谢谢!