Spring Request Mapping Mis
I am using Spring mapping. And have the following mapping code. The problem is there are like 20 possible misspelling for these and others that need to be accounted for. Rather than add a RequestMapping for each url which would be like 30 or 40, is开发者_开发技巧 there a way to simply redirect these. I know the way I am doing is not clean and would appreciate advice on how to keep my request mappings to a minium. Thanks.
@RequestMapping("/protect")
public String protect(Model model) {
QuickResponse qr = createQR();
model.addAttribute("qr", qr);
return "qr_general";
}
I am unsure as to what can be misspelled, but I am thinking you are referring to the path that is being mapped to.
The @RequestMapping
annotation's default value
member takes String[]
, so you should be able to put all of your mappings in one location:
@RequestMapping({"/protect", "/protekt", "/proteckt", "/protext"})
public String protect(Model model) {
QuickResponse qr = createQR();
model.addAttribute("qr", qr);
return "qr_general";
}
精彩评论