2011-12-13 58 views
0

我擁有帶有spring-security-core插件的Grails應用程序。在我的conf /春/ resources.groovy文件中,我定義彈簧安全,非英文字符(如「š,č,ć,ž,đ」)登錄失敗的密碼

import org.springframework.security.authentication.encoding.PlaintextPasswordEncoder 
beans = { 
    passwordEncoder(PlaintextPasswordEncoder) 
} 

,所以我可以保存明文密碼保存在MySQL數據庫就像是在意見/登錄/ auth.gsp我還添加了這裏Spring security no password encoding

解釋在<head>方框

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

和在DataSource.groovy中

url = "jdbc:mysql://localhost:3306/blabla?useUnicode=true&characterEncoding=utf8" 

我使用username =ččč和password =ččč成功創建了用戶,但是當我嘗試使用此用戶登錄時,我得到登錄錯誤「對不起,我們無法找到具有該用戶名和密碼的用戶。我檢查數據庫和用戶存在與這些字段值。

我試圖用一些其他用戶用戶名= admin,密碼= admin登錄,它工作正常。 所以我想這與j_username和j_password不接受非英文字符有關......如何使登錄表單字段接受utf-8字符集?

我:

的Grails 1.3.7

彈簧安全核心1.2.6

STS 2.8.1

使用mysql-connector-java的5.1.18

Windows 7

回答

0

首先建議:不要使用明文密碼。第二個建議:檢查發送到數據庫的SQL查詢。你需要這個在Config.groovy中看到Hibernate的聲明和其參數值:

log4j = { 
     debug 'org.hibernate.SQL' 
     trace 'org.hibernate.type' 
} 
+0

我知道我should't使用明文密碼,但這是一些簡單的項目,明文真的是我需要的東西......反正以後在Config.groovy中實現我在控制檯中看到 DEBUG dao.DaoAuthenticationProvider - 用戶'沒有找到 ...和登錄用戶名我輸入了ččč,而不是Ä?Ä?Ä? ...所以我想這個問題仍然是爲什麼字段不接受utf-8字符集?我該如何做到這一點:( – tibortru 2011-12-13 23:10:11