新手集成SSH问题,简单的用户登录都不行
自学STRUTS2+SPRING3+HIBERNATE3 发现问题无法解决,贴出以下代码
1、applicationContext.xml:...
<!-- 配置Hibernate 数据源-->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/xyssh" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<!-- 配置Hibernate SeesionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="myDataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- 配置其他beans-->
<bean id="LoginAction" class="com.xyssh.system.action.LoginAction"
scope="prototype">
<property name="userDao" ref="UserDao"></property>
</bean>
<bean id="UserDao" class="com.xyssh.system.dao.UserDao" scope="prototype">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
2、struts.xml:<struts>
<package name="user" namespace="/" extends="struts-default">
<action name="login" class="com.xyssh.system.action.LoginAction" >
<result>
<param name="success">/login.jsp</param>
<param name="error">/index.jsp</param>
</result>
</action>
</package>
</struts>
3、web.xml<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
4、LoginAction.javapublic class LoginAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = -3945074126919510909L;
private String code;
private String password;
private UserDao userDao;
public String execute() {
//查找用户
List<User> users = getUserDao().findByProperty("code", code);
if (users.size() == 0){
return "error";
}
User user = users.get(0);
//判断密码
if (user.getPassword().equals