很简单的SSH整合,可我访问页面总报404,请高手帮忙
这是我的源码
dao文件是直接用myeclipse生成的文件
service文件源码
public class UserService {
private UserDAO userDAO;
public User regist(User user){
userDAO.save(user);
return user;
}
public UserDAO getUserDAO() {
return userDAO;
}
public void setUserDAO(UserDAO userDAO) {
this.userDAO = userDAO;
}
}
这是struts文件的Action类private UserService userService;
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;// TODO Auto-generated method stub
User user = new User();
user.setUsername(userForm.getUsername());
user.setPassword(userForm.getPassword());
user.setEmail(userForm.getEmail());
if(userService.regist(user) != null){
return mapping.findForward("success");
}else{
ActionErrors errors = new ActionErrors();
errors.add("username",new ActionError("errors.username_is_used"));
saveErrors(request, errors);
userForm.setPassword("");
userForm.setPassword2("");
return mapping.findForward("failure");
}
}
vo文件也是直接映射出来的没有改动
这是applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/waphaha</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>111111</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/tie/vo/User.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userDAO" class="org.tie.dao.UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userService" class="org.tie.service.UserService"
abstract="false" singleton="true" lazy-init="default"
autowire="default" dependency-check="default">
<property name="userDAO">
<ref local="userDAO" />
</property>
</bean>
<bean name="/user" class="org.tie.struts.action.UserAction"
abstract="false" singleton="false" lazy-init="default"
autowire="default" dependency-check="default">