Thursday, October 20, 2011

Redirecting from index.gsp | Groovy on Grails

Groovy on Grails: Redirecting from index.gsp
1. Create a TagLib file
grails-app\taglib\MyAppTagLib.groovy

2. Define a method that routes to your first page
class MyAppTagLib {
def redirectMainPage = {
response.sendRedirect("${request.contextPath}/myController/welcomePage/")
}
}


3. Change your index.gsp to contain only:


Note: One advantage to this approach is that you have a coding opportunity over simply mapping the "/" url.

For example, if you want to provide features or data based on a specific user's login id.

No comments:

Post a Comment