0

So, I am running my grails application and the URL generated from the localhost is http://localhost:8888/appname/

When I enter the above link in the URL, I want it to be redirected to http://localhost:8888/appname/controller1/action1

This is my UrlMappings,

static mappings = {
    "/"(controller: 'controller1', view: 'action1')
    .
    .
    .
}

When I do this, I am not getting the desired output. The URL doesn't change. But, I am getting the page desired. However, certain elements of the page don't load (For example, I have a jqGrid).

Please help!

John Giotta
  • 16,432
  • 7
  • 52
  • 82
Spicado
  • 65
  • 8

2 Answers2

0

you should do

"/"(controller: 'controller1', action: 'action1')

i.e in place of view it should be action

ABC
  • 4,263
  • 10
  • 45
  • 72
0

"/"(redirect: [controller: 'controller1', action: 'action1'])

https://grails.github.io/grails-doc/latest/guide/theWebLayer.html#redirectMappings

Dan Fischer
  • 3,769
  • 1
  • 14
  • 10
  • Tried this. But getting the following error. "Unable to establish controller name to dispatch for [null]. Dynamic closure invocation returned null. Check your mapping file is correct, when assigning the controller name as a request parameter it cannot be an optional token!" – Spicado Feb 19 '15 at 19:43
  • Did you try the other format, `"/"(redirect: '/controller1/action1')? Also, what version of Grails are you using? Redirects in url mappings appear to have been introduced in Grails 2.3. – Dan Fischer Feb 19 '15 at 19:52
  • Yes, I tried that too. Same error. I am using 2.3.7! – Spicado Feb 19 '15 at 20:00