开发者

Retrieving a parameter from GSP in Controller, Grails

I do have this code on my demo.gsp file. But I´m new to grails and I don´t really know very well how to retrieve the value of the input on m开发者_Python百科y Controller to validate it like i.e "inputResult=="hi" then ok else bad".

<g:form action='${postUrl}' method='post' id='loginForm' class='cssform' autocomplete='off'>
 <p>
   <label for="password">
    <g:message code="access.code"/>:
   </label>
 </p>
 <p>
   <input name="j_password" class="loghominput" id="password" type="password"/>
 </p>
 <div class="greenbutton2">
  <a href="#" onclick="document.getElementById('loginForm').submit(); return false">
  <g:message code="home.enter"/></a><input type="submit" style="display:none" value="Enter"/>
 </div>
</g:form>

My Controller is like this.

class AskDemoController {

    def demo = {

    }
}

Thanks!


You can access parameters submitted by your form in the controller by using the params object. Something like this...

def somethingInTheForm = params.nameOfTheParam;

if (somethingInTheForm){
   render 'good'
}else{
   render 'bad'
}

Take a look here for documentation.

However - i would suggest going through some to the Tutorials to gain a better understanding of the power of grails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜