当前位置: 代码迷 >> J2EE >> 请问一个用S2SH注册的有关问题
  详细解决方案

请问一个用S2SH注册的有关问题

热度:88   发布时间:2016-04-22 02:06:19.0
请教一个用S2SH注册的问题
我用S2SH整合,弄一个注册的小程序,但老提示说找不到路径,不知道怎么回事,各位帮我看看吧。
下面是regist.jsp
Java code
${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>

下面是web.xml
XML code
<?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>

下面是application.xml
XML code
<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.xml
XML code
<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>


dao层
Java code
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);    }}
  相关解决方案