Spring - Annotation Based Controller - RequestMapping based on query string
Solution 1:
Yes, you can use the params element:
@RequestMapping("/test.html", params = "day=monday")
public void writeMonday() {
}
@RequestMapping("/test.html", params = "day=tuesday")
public void writeTuesday() {
}
You can even map based on the presence or absence of a param:
@RequestMapping("/test.html", params = "day")
public void writeSomeDay() {
}
@RequestMapping("/test.html", params = "!day")
public void writeNoDay() {
}
Solution 2:
or you could do something like:
@RequestMapping("/test.html")
public void writeSomeDay(@RequestParam String day) {
// code to handle "day" comes here...
}