Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Grails is a MVC framework. If you want to map an URL directly to a GSP (without redirection through a controller and action) you need to explain this to grails within your <code>UrlMappings.groovy</code>. There you can define your "shortcuts". E.g.:</p> <pre><code>static mappings = { "/$viewName"(view:"/index") { constraints { viewName([some constraints]) } } } </code></pre> <p>Which will render <code>views/index.gsp</code> without going through a controller. If you do NOT define a controller mapping (or at least a view mapping) for those URLs, you canNOT use grails filters:</p> <p>If you really want to intercept ALL requests, you can add a servlet filter to your grails application like this:</p> <pre><code>import javax.servlet.* import org.springframework.web.context.support.WebApplicationContextUtils; class TestFilter implements Filter { def applicationContext void init(FilterConfig config) throws ServletException { applicationContext = WebApplicationContextUtils.getWebApplicationContext(config.servletContext) } void destroy() { } void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("this filter has been called"); } } </code></pre> <p>In here you can do your redirections or renderings based on the <code>applicationcontext</code> and the current <code>request</code>.</p> <p>You need to add this filter to your <code>web.xml</code>. On how to do this, have a look at: <a href="https://stackoverflow.com/questions/9924616/how-do-i-use-a-servlet-in-my-grails-app/9928748#9928748">How do i use a servlet in my grails app?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload