Sunday, September 7, 2008

How to redirect url from index.gsp?

   In the newly version of Grails,the index page is index.gsp but not index.jsp.you can't change the file name directly,it doesn't work.I think an alternative method is writen an TagLib.for example:
1,create a taglib file under  grails-app/taglib
TestTaglib
2,define a new tag
def redirectPage={ attrs->
  def url=attrs.get('url')
   response.sendRedirect("${request.contextPath}"+url)
}
3.in the index.gsp,writen like this:


3 comments:

marmotte said...

"3.in the index.gsp,writen like this:" , where the end ????

Anonymous said...

<g:redirectpage url="/race/search">

Anonymous said...

""