Reputation: 731
springmvc @RequestMapping in my code
@RequestMapping("/{c1}-{c2}-{c3}-{c4}.htm")
public void category(@PathVariable("c1") Integer c1,@PathVariable("c2") Integer c2,@PathVariable("c3") Integer c3,@PathVariable("c4") Integer c4){
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
System.out.println(c4);
}
@RequestMapping("/{c1}-{c2}-{c3}-{c4}-{label}.htm")
public void label(
@PathVariable("c1") Integer c1,
@PathVariable("c2") Integer c2,
@PathVariable("c3") Integer c3,
@PathVariable("c4") Integer c4,
@PathVariable("label") Integer label){
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
System.out.println(c4);
System.out.println(label);
}
I want url "/2-5-3-138-8.htm" mapping the "label" method~
but actual mapping the "category" method and Parse out the parameters:
How can I let this path "/2-5-3-138-8.htm" to match the "label" method?
Upvotes: 0
Views: 352
Reputation: 4040
try with the patterns updated as follow:
@RequestMapping("/{c1:[0-9]+}-{c2:[0-9]+}-{c3:[0-9]+}-{c4:[0-9]+}.htm")
...
@RequestMapping("/{c1:[0-9]+}-{c2:[0-9]+}-{c3:[0-9]+}-{c4:[0-9]+}-{label}.htm")
Upvotes: 2