考慮下面的例子:避免斜槓(/)彈簧RequestMapping之間
@Controller
@RequestMapping({"/home"})
public class Home {
@RequestMapping(value = { "", "/" })
public String index() {
return "home";
}
@RequestMapping(value = { "-of-{id}" })
public String of(@PathVariable("id") String id) {
System.out.println(id);
return "home";
}
}
指數()被映射到 '/家' 和 '/家/' 完美;但是當我想將它映射到'/ home-of- {id}'時,(id)映射到'/ home/-of- {id}'。
Spring自動在'/ home'和'-of- {id}'之間添加一個斜槓,但我想消除它,任何建議?