0

I am using grails 1.3.7. I am sending username and password from my view page to controller. And it's rendering correctly on browser. But I need to write query for collect data with that username and password from database. But I have no idea how to write query in grails controller. Can anyone please help me on this ? Here is my action below where I want to write query for logging in to the home page >>>

def loginAction = {
    def username = params?.username
    def password = params?.password
    def val = username + "  ---  " +password
    render val
}
4

1 回答 1

2

就像是:

def loginAction = {
    def username = params?.username
    def password = params?.password
    User user = User.findByUsername(username)
    def val = user?.password == password ? 'Valid' : 'Invalid'
    render val
}

但你真的应该阅读 GORM 的文档 - http://grails.org/doc/latest/guide/GORM.html

于 2013-04-18T10:57:01.657 回答