请教一个用S2SH注册的问题
我用S2SH整合,弄一个注册的小程序,但老提示说找不到路径,不知道怎么回事,各位帮我看看吧。
下面是regist.jsp
${user.msg} <s:form action="regist" method="post"> 用户名:<s:textfield name="user.username" size="20"/><br/> 密码:<s:password name="user.userpassword" size="20"/><br/> <s:submit value="注册"/> </s:form>
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <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> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> </bean> <bean id="userDAOImpl" class="dao.UserDAOImpl"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <bean id="userService" class="service.UserServiceImpl2"> <property name="userDAO"> <ref local="userDAOImpl"/> </property> </bean> <bean id="Regist" class="action.Regist"> <property name="userService"> <ref local="userService"/> </property> </bean>
<struts> <constant name="struts.devMode" value="true"/> <package name="Regist11" extends="struts-default" namespace="/my"> <action name="regist" class="Regist"> <result name="success">/regist.jsp</result> </action> </package></struts>
package dao;import java.util.List;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import entity.User;public class UserDAOImpl extends HibernateDaoSupport implements UserDAO { public boolean exist(User user) { System.out.println("正在验证数据......"); String hql="from User u where u.username='"+user.getUsername()+"'and u.userpassword='"+user.getUserpassword()+"'"; List userList=this.getHibernateTemplate().find(hql); System.out.println("共找到数据:"+userList.size()); if(userList.size()>0&&userList!=null){ return true; }else{ return false; } } public void saveUser(User user) { this.getHibernateTemplate().save(user); }}
package service;import dao.UserDAO;import entity.User;public class UserServiceImpl2 implements UserService2 { private UserDAO userDAO; public UserDAO getUserDAO() { return userDAO; } public void setUserDAO(UserDAO userDAO) { this.userDAO = userDAO; } public boolean exist(User user) { return userDAO.exist(user); } public void saveUser(User user) { userDAO.saveUser(user); } }
package entity;import java.io.Serializable;public class User implements Serializable{ /** * */ private static final long serialVersionUID = 1L; private String msg=""; private Integer userid; private String username; private String userpassword; public Integer getUserid() { return userid; } public void setUserid(Integer userid) { this.userid = userid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getUserpassword() { return userpassword; } public void setUserpassword(String userpassword) { this.userpassword = userpassword; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } }
<?xml version="1.0"?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping package="entity"> <class name="User" table="WL_USER"> <!--定义id--> <id name="userid" column="USERID"> <generator class="increment"/> </id> <!--定义用户名--> <property name="username" type="string" column="USERNAME"/> <!--定义密码--> <property name="userpassword" type="string" column="PASSWORD"/> </class></hibernate-mapping>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration> <session-factory> <property name="hibernate.connection.url">jdbc:mysql://localhost/mytestdb</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">true</property> <mapping resource="entity/User.hbm.xml"/> </session-factory></hibernate-configuration>
package action;import service.UserService2;import com.opensymphony.xwork2.ActionSupport;import entity.User;public class Regist extends ActionSupport{ private String msg=""; private User user; private UserService2 userService; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public UserService2 getUserService() { return userService; } public void setUserService(UserService2 userService) { this.userService = userService; } public String execute() throws Exception { if(userService.exist(user)){ msg="注册成功"; user.setMsg(msg); userService.saveUser(user); }else{ msg="注册失败"; user.setMsg(msg); }; return "success"; }// public String getMsg() {// return msg;// } }
${user.msg} <s:form action="regist" method="post"> 用户名:<s:textfield name="user.username" size="20"/><br/> 密码:<s:password name="user.userpassword" size="20"/><br/> <s:submit value="注册"/> </s:form>