0

I'm trying to get parameters from the url using param in a controller. My url is: .../index?format=json

I've tried to get the params from the following two methods:

def format = params.format
def parameters = getParams()

The below is what I get in the debug results:

screenshot

My question is why the format value isn't coming through in the code?

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
pinguinos
  • 123
  • 12

1 Answers1

2

The format parameter gets populated by the type of content you are asking for (JSON, XML, etc). So, a request parameter called format will get overridden.

See here for more details: Grails 2.3.x: get the value of URL parameters

Community
  • 1
  • 1
Bobby Warner
  • 653
  • 6
  • 8
  • Got it. This works if I change the request to /index.json rather than requesting the format through a variable. I didn't realize format was a reserved name. – pinguinos Dec 01 '14 at 03:10
  • Ordinarily this would be the part where you accept this as the correct answer – Burt Beckwith Dec 01 '14 at 06:52