Erro ao passar parametros?
13/11/2013 10:50
| Error 2013-11-13 10:28:48,996 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /freako/usuario/login - parameters:
login: iranvital
senha: iranvital
No signature of method: freako.Usuario.findByLoginAndSenha() is applicable for argument types: (java.lang.String, [B) values: [iranvital, [55, 100, 111, 50, 66, 103, 56, ...]]
Possible solutions: findByLoginAndSenha([Ljava.lang.Object;). Stacktrace follows:
Message: No signature of method: freako.Usuario.findByLoginAndSenha() is applicable for argument types: (java.lang.String, [B) values: [iranvital, [55, 100, 111, 50, 66, 103, 56, ...]]
Possible solutions: findByLoginAndSenha([Ljava.lang.Object;)
Line | Method
->> 111 | methodMissing in org.grails.datastore.gorm.GormStaticApi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 28 | doCall in freako.UsuarioController$_closure1
| 195 | doFilter . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . in java.lang.Thread
<g:form name="formLogin" url="[controller:'usuario', action:'login']" >
Login:<input type="text" name="login" /><br />
Senha:<input type="password" name="senha" /><br />
<input type="submit" value="Entrar" />
</g:form>
def login = {
def loginUsuario = params["login"]
def senhaUsuario = params.senha
def usuario = Usuario.findByLoginAndSenha(loginUsuario, senhaUsuario.encodeAsPassword())
if (usuario) {
session["usuario"] = usuario
redirect(action:"lista", controller:"link")
} else {
render("Usuario não encontrado no sistema!")
}
}
def login = {
def usuario = Usuario.findByLoginAndSenha(params.login, params.senha.encodeAsPassword())
if (usuario) {
session["usuario"] = usuario
redirect(action:"lista", controller:"link")
} else {
render("Usuario não encontrado no sistema!")
}
}
| Error 2013-11-13 12:45:50,358 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /freako/usuario/login - parameters:
login: iranvital
senha: iranvital
No signature of method: freako.Usuario.findByLoginAndSenha() is applicable for argument types: (java.lang.String, [B) values: [iranvital, [55, 100, 111, 50, 66, 103, 56, ...]]
Possible solutions: findByLoginAndSenha([Ljava.lang.Object;). Stacktrace follows:
Message: No signature of method: freako.Usuario.findByLoginAndSenha() is applicable for argument types: (java.lang.String, [B) values: [iranvital, [55, 100, 111, 50, 66, 103, 56, ...]]
Possible solutions: findByLoginAndSenha([Ljava.lang.Object;)
Line | Method
->> 111 | methodMissing in org.grails.datastore.gorm.GormStaticApi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 26 | doCall in freako.UsuarioController$_closure1
| 195 | doFilter . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . in java.lang.Thread
def usuario = Usuario.findByLoginAndSenha(loginUsuario, senhaUsuario.encodeAsPassword())
package freako
import java.security.MessageDigest
import org.apache.commons.codec.binary.Base64
class PasswordCodec {
static encode = { String s ->
MessageDigest md = MessageDigest.getInstance('SHA')
md.update s.getBytes('UTF-8')
Base64.encodeBase64 md.digest()
}
}
package freako
class Usuario {
String login
String hashSenha
String email
String senha
void setSenha(String valor){
this.senha = valor
if(valor != null){
this.hashSenha = valor.encodeAsPassword()
}
}
static transients = ['senha']
static hasMany = [links:Link]
static constraints = {
login(nullable:false,blank:false,unique:true)
hashSenha(nullable:false,blank:false)
email(email:true)
}
String toString() {
"${this.login}"
};
}
Para se registrar, clique aqui.