grailshttprequestgrails-controller

HTTP GET request in Grails with urls


I've got a problem using a HTTP GET request in Grails with urls. My plan is to read saved params out of an url. Like there is a param called address with saved content. For example: http://mydomain.de/property?address=Alexanderplatz+3%2C+Berlin%2C+Deutschland=&submit=start . Here I commit my entered address into a url. There's another page, on which I'm going to be redirected after clicking the submit-button, and there is a form with an inputfield named "address". In this inputfield I'd like to commit the saved address from the given url as a default value. Do I need to configure the controller of my grails-app in a special way? I have the following function:

def create() {
    render(view: "form")
}

How is it possible to do a HTTP GET request in Grails?


Solution

  • I have found the perfect solution right here: Grails pass data to view from controller

    in PropertiyController.groovy:

    def index = { 
    
        def parameter = 
        request.getParameter("address") 
       }
    

    and:

    def create() {
        def address = params.address;
    
        render(view: "form", model:[viewAddress:address]);
    }
    

    The only thing to change additional is to give the input-field the missung param linke this:

    value="${viewAddress}"
    

    It works perfectly!