0
votes

I've got a simple controller in my Grails app with simple mappings...

TCacheController {
  def index ={}
  def list= {}

}

"/tcache/" (controller: "TCache"){
   action = [GET: "index"]
}

"/tcache/items" (controller: "TCache"){
   action = [GET: "list"]
}

All of my URL's are of the form http://.../tcache/*, and everything works fine. The problem arises when I use <g:actionSubmit> in a view like this...

<g:form controller="TCache">

   <g:actionSubmit class="delete" action="list" value="List Items">

The submit works, but in my list action I have a redirect in case something goes wrong, and that redirect is resulting in 404 because Grails is sending to /TCache/.., not /tcache/...

Under what circumstances is Grails changing upper/lower case of the URI, and is there a way to force it to always use /tcache? I tried using controller="tcache" in the form, but then the action stops working, probably because Grails can't find the controller.

1
What does the code for the redirect in your list action look like? - david
The code for the list action basically goes and gets some data then does a render[view:'list'] which goes to list.gsp. If any exceptions occur in the action, I catch it and do a redirect(action:'index'), and that's when I get the 404 because it tries to redirect to /TCache/... when it should be redirecting to /'tcache/..., I'm trying to figure why it's using upper case. - raffian

1 Answers

1
votes

I managed to figure this out on my own. Grails' convention over configuration is great, but sometimes Grails does not always guess correctly.

In the controller, when rendering a view, using literal paths ensures that Grails will not have to guess anything...

TCacheController {
  def index ={}
  def list= {
     render( view: "/tcache/listitems", model:[])
}

instead of...

render( view: "listitems", model:[])

In my case, having multiple controllers, it appears Grails got a bit confused and attempted to prefix /TCache/.. for the full render view path when it should have used /tcache/listitems.