首先,我們需要對使用者名稱進行非空校驗,為了避免使用者輸入兩個空串,我們在此自定義去空轉換器,springmvc.xml的定義:
12<
bean
id="conversionservice"
class
="org.springframework.format.support.formattingconversionservicefactorybean"
>34
5<
property
name
="converters"
>
6<
list
>
7<
bean
class
="cn.cuibusi.common.conversion.customconverter"
>
bean
>
8list
>
9property
>
10bean
>
然後 我們需要在處理器介面卡中引入配置的去空轉換器:
12<
mvc:annotation-driven
conversion-service
="conversionservice"
/>
然後是我們的自定義去空類:
1public
class customconverter implements converter12}
13 } catch
(exception e)
16return
null;17
}1819 }
然後是登入controller:
1@autowired
2private
buyerservice buyerservice;
3@autowired
4private
sessionprovider sessionprovider;5//
提交登陸
最後時md5加密後再進行16進製制轉換:
1public
string encodepassword(string password) catch
(nosuchalgorithmexception e)
19return
newstring(encodehex);
20 }
開發常用 校驗表單 密碼的校驗
要求 必填,密碼應為8 20位字元,必須包含數字 字母 下劃線中的兩種以上 validate.js檔案內容 檢查密碼是否合法 function checkpwd userpassword if userpassword.length 20 userpassword.length 8 if 0 9 g...
表單提交前 校驗方法
有時在表單提交前,需要對所填報或者選擇的資料進行校驗,只有先通過校驗的資料才能到達後台的action中,這樣就省去了每次提交都到action中去校驗的步驟,能提高效率。方法就是在確定前執行指令碼,去驗證 代表乙個bean return checkselectiteam js 校驗方法 functio...
Yii2 0 密碼加密及密碼校驗
1.yii2.0加密及校驗 password為輸入的密碼,它是沒有經過加密的字串 hash password為原先加密的密碼 一般用法 step1 將密碼 123456 加密為 hash password step2 將 hash password存入資料庫 step3 從資料庫中查詢出密碼,賦給變...