-
-
Notifications
You must be signed in to change notification settings - Fork 967
Description
The parameters used in UrlMappings get lost during forward(). This is important
See demo application here -
https://github.com/rogovskiy/grailsForwardIssue2
Simple HomeController prints passed in parameter "id". If another parameter forward is passed it forwards to another action doing similar.
class HomeController {
def index() {
if (params.forward) {
forward(action: 'imForwardedTo')
} else {
render(text: "ID is ${params.id}")
}
}
def imForwardedTo() {
render(text: "Forward ID is ${params.id}")
}
}
...
UrlMappings.groovy
"/forward/$id"(controller: 'home', action: 'index')
Results
http://localhost:8080/home/index?id=31 ==> ID = 31 (GOOD)
http://localhost:8080/home/index?id=31&forward=true ==> Forwarded ID = 31 (GOOD)
http://localhost:8080/forward/31 ==> ID = 31 (GOOD)
http://localhost:8080/forward/31?forward=true ==> Forwarded ID = null (BAD)
Expected Behaviour
All parameters gets passed to the next action using forward().
Actual Behaviour
All parameters EXCEPT the ones used in the URL mapping passed to the next action.
Environment Information
- Operating System: Windows
- Grails Version: 3.1.15
- JDK Version: 1.8