Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The easiest way to redirect to the last page, is to use the URI directly:</p> <pre><code>&lt;g:link controller="user" action="logout" params="[targetUri: (request.forwardURI - request.contextPath)]"&gt;Logout&lt;/g:link&gt; </code></pre> <p>(<code>request.forwardURI</code> is the complete URL as displayed in the browser, while <code>request.contextPath</code> is the URL part representing the app context, eg. "<a href="http://localhost:8080/yourApp" rel="nofollow noreferrer">http://localhost:8080/yourApp</a>" - thus, the result of removing the context path from the forward URI is the app-relative URI, eg. "/mycontroller/myaction")</p> <p>In your logout action simply redirect to this URI:</p> <pre><code>def targetUri = params.targetUri ?: "/" redirect(uri: targetUri) </code></pre> <p>AFAIK, using the referrer is not entirely safe, because this relies on the user agent (browser) to append the referrer HTTP header (which may have been disabled).</p> <p><strong>As to your 2nd question:</strong> Grails automatically interprets list or map attribute values in GSPs as Groovy expressions. So, this</p> <pre><code>&lt;g:link controller="user" action="logout" params="[currentController: params.controller, currentAction: params.action]"&gt;Logout&lt;/g:link&gt; </code></pre> <p>is equivalent to</p> <pre><code>&lt;g:link controller="user" action="logout" params="${[currentController: params.controller, currentAction: params.action]}"&gt;Logout&lt;/g:link&gt; </code></pre> <p>and wrapping parts of this expression again in <code>${...}</code> seems to confuse the GSP compiler.</p> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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