Skip to content

forward() loses parameters used in UrlMappings #10583

@rogovskiy

Description

@rogovskiy

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

Example Application

https://github.com/rogovskiy/grailsForwardIssue2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions