例如:
@RequestMapping("A")
public String commonRequestPage() {
return "A";
}
@RequestMapping("B")
public String commonRequestPage() {
return "B";
}
@RequestMapping("*")
public String commonRequestPage() {
return "*";
}
我尝试了统配符,行不通,有经验的请问,这种单纯跳转的情况怎么处理,难道真的要一条一条写?
http://docs.spring.io/spring/docs/4.2.5....
基本使用方法官方文档都是有说的
给你个例子,之前做的项目创建了一个专门用来跳转页面的Controller,其中跳转的方法是这么写的:z
@RequestMapping("{root}/{page}")
public String toPage(@PathVariable String root, @PathVariable String page){
return root+"/"+page;
}
这时我的请求路径可以是:localhost:8080/xxxx/page/index.do 。 page
和index
会分别传入方法参数root 和page中,最终跳转到page/index.jsp页面(page是index.jsp所在的文件夹)