新人求教,SSH整合使用getHibernateTemplate()方法老是报错,找了好几天了,我就有这么点分数了
我就做的一个bbs的登陆功能,总是报错啊
是不是我的applicationContext.xml文件配置有问题啊。。我最近新学的,还不太明白
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property>
<property name="url" value="jdbc:sqlserver://localhost:1433;DatabaseName=BBS"></property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
<property name="maxActive" value="100"></property>
<property name="maxIdle" value="30"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/bbs/po/BoardManagerTable.hbm.xml</value>
<value>com/bbs/po/BoardType.hbm.xml</value>
<value>com/bbs/po/CommentTable.hbm.xml</value>
<value>com/bbs/po/InvitationTable.hbm.xml</value>
<value>com/bbs/po/ManagerTable.hbm.xml</value>
<value>com/bbs/po/UserInfoTable.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="allowCreate">
<value>true</value>
</property>
</bean>
<bean id="userInfoDao" class="com.bbs.dao.UserInfoDaoImpl" scope="singleton">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="userLoginService" class="com.bbs.service.userLoginService">
<property name="uiDao" ref="userInfoDao"></property>
</bean>
<bean id="UserLoginAction" class="com.bbs.action.UserLoginAction" scope="prototype">
<property name="uesrLogSer" ref="userLoginService"></property>
</bean>
</beans>
这是我的Action
package com.bbs.action;
import com.bbs.service.userLoginService;
import com.opensymphony.xwork2.ActionSupport;
public class UserLoginAction extends ActionSupport
{
private static final long serialVersionUID = 1L;
String userNick,userPassword;
userLoginService uesrLogSer = new userLoginService();
public String getUserNick()
{
return userNick;
}
public void setUserNick(String userNick)
{
this.userNick = userNick;
}
public String getUserPassword()
{
return userPassword;
}
public void setUserPassword(String userPassword)
{
this.userPassword = userPassword;
}
public String execute() throws Exception
{
boolean isReally = uesrLogSer.checkUser(this.userNick, this.userPassword);
//判断密码是否正确
if(isReally)
{
return SUCCESS;
}
else
{
return INPUT;
}
}
}
这是service
package com.bbs.service;
import java.util.List;
import com.bbs.dao.UserInfoDaoImpl;
import com.bbs.po.UserInfoTable;
import com.bbs.serviceIntf.userLoginServiceIntf;
public class userLoginService implements userLoginServiceIntf
{
UserInfoDaoImpl uiDao;
public UserInfoDaoImpl getUiDao()
{
return uiDao;
}
public void setUiDao(UserInfoDaoImpl uiDao)
{
this.uiDao = uiDao;
}
public List<UserInfoTable> findOneUserInfoByNick(String userNick)
{
return this.uiDao.findOneUserInfoByNick(userNick);
}
public boolean checkUser(String userNick, String userPassword)
{
boolean isReally = false;
List<UserInfoTable> uiList = this.findOneUserInfoByNick(userNick);
for(int i=0;i<uiList.size();i++)
{
UserInfoTable ui = (UserInfoTable) uiList.get(i);
if(ui.getUserPassword().equals(userPassword))
{
isReally = true;
}
}
return isReally;
}
}
这是dao
package com.bbs.dao;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.bbs.daoIntf.UserInfoDaoIntf;
import com.bbs.po.UserInfoTable;
public class UserInfoDaoImpl extends HibernateDaoSupport implements UserInfoDaoIntf
{
public void deleteUserInfo(UserInfoTable userInfo)
{
this.getHibernateTemplate().delete(userInfo);
}
@SuppressWarnings("unchecked")
public List<UserInfoTable> findAllUserInfo()
{
String HQL = "from UserInfoTable ui order by ui.userId desc";
List<UserInfoTable> allUserInfo = (List<UserInfoTable>)this.getHibernateTemplate().find(HQL);
return allUserInfo;
}
@SuppressWarnings("unchecked")
public List<UserInfoTable> findOneUserInfoByNick(String userNick)
{
return (List<UserInfoTable>)this.getHibernateTemplate().find("from UserInfoTable uit where uit.userNick=?",userNick);
}
public void saveUserInfo(UserInfoTable userInfo)
{
this.getHibernateTemplate().save(userInfo);
}
public void updataUserInfo(UserInfoTable userInfo)
{
this.getHibernateTemplate().update(userInfo);
}
}
请问哪里有问题啊。。。。我都要崩溃了