Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7539139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:18:14+00:00 2026-05-30T07:18:14+00:00

UrlMappings are a great feature for links, but do they also work for forms?

  • 0

UrlMappings are a great feature for links, but do they also work for forms?

Suppose we have a mapping like this:

"/map/$a" {
    controller="form"
    action="show"
}

a <g:link controller="form" action="show" params="[a:'test'] /> will now be rewritten as
<a href="/appname/map/test" />

But a form like this:

<g:form controller="form" action="show">
   <g:textField name="a" />
</g:form>

will not have the same effect. It will result in requesting /appname/form/show?a=whatever

I know that a form can’t be rewritten at HTML-creation time like a link – mainly because the value of the parameter is not known at this time, but I hoped that this URL would be redirected to the “nice” URL.

Is there a way to do stuff like that in grails? Or do I have to write my own redirect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:18:15+00:00Added an answer on May 30, 2026 at 7:18 am

    I guess I’ve found the answer:

    URL-Rewriting seems only to work at the time when the HTML gets rendered.
    So

    <g:form controller="form" action="show" params="[a:'test']">
       <g:textField name="b" />
    </g:form>
    

    will result in /appname/map/test. But that’s not what I want – I want the URL to be rewritten when the form gets submitted.

    So I came up with a redirect action:

    class FormController {
    
        def index() { }
        def show() {
            render("yep"+params.a)
        }
        def submit() {
            redirect(controller:'form',action:'show',params:params)
        }
    }
    

    and I rewrite my form as

    <g:form controller="form" action="submit">
       <g:textField name="a" />
    </g:form>
    

    This seems to work great (at the cost of one redirect)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked for the answer to this on Google and stackoverflow, but unfortunately
I would like to basically do a URL rewrite in UrlMappings.groovy, for example: /pub/cdn/$version/**(uri:
I am using IIS7 and urlMappings to map some urls to actual pages. Example:
I'm trying to create simple urlMapping, but it doesn't work. It goes into constructor,
I have a URL like: /test/abs/rdc/tx.js and I need to be able to get
Consider the following Grails URL mapping: class UrlMappings { static mappings = { /something/${foo_id}/
I would like to have URL mappings that I'm having with spring framework like
I have the following urlmappings: /loader/ { action = [POST:savep] controller = 'loader' }
I have the next scenario in my UrlMappings.groovy: /user/$action? (controller:user) /admin/$action? (controller:user) 500(controller:error, action:show)
I have the following UrlMapping in my Grails UrlMappings class: /$something/ { controller =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.