在spring2.0中,bean沒有“singleton”這個屬性,而是在“scope”中對它進行設定。“scope”可以設定為“singleton”和“prototype”默認情況下是“singleton”即和原先的“singleton=true”性質一樣,如果要實現單例模式則將“scope”設定為“prototype”,即和原先版本的“singleton=false”一樣。參考文檔鏈接地址:
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
根據用戶名和密碼進行校驗的方法
public boolean verify(String userName, String userPwd) {
final String HQL="FROM UserTable u where u.userName=? and u.userPwd=?";
String[] hqlParameter=new String[2];
hqlParameter[0]=userName;
hqlParameter[1]=userPwd;
List list=this.getHibernateTemplate().find(HQL,hqlParameter);
if(list.size()>0){
return true;
}
return false;
}