To redirect to an initial page from the 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:
<g:redirectMainPage/>
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.
Subscribe to:
Post Comments (Atom)
5 comments:
Am I missing something? That contains only what...?
Oh blogger has stripped your tags I assume :-P
Yeah I find it strange that something this simple isn't available already in a tag. JSP tags are on the road map from what I gather so perhaps that's why this wasn't re-implemented.
James.
Why not map the / URL to your controller/action?
[]s,
Lucas
Thanks for catching the mistake, thats what I get for not reviewing it ... too hasty. :)
That's help me greatly !
See on Stackoverflow
Post a Comment