什么错误也不报,但是数据添加不成功!数据库没有东西
郁闷死了!
注册代码:<s:form action="register.action" namespace="member" theme="simple" method="get">
<s:textfield label="用户名" name="member.userId" id="userId" onblur="checkUser(this)"></s:textfield><div id="userInfor"></div>
<s:hidden name="member.userName" id="userName"></s:hidden>
<s:textfield label="密  码" name="member.userPwd" id="userPwd" onblur="checkpwd(this)"></s:textfield><div id="pwdinfo"></div>
<s:textfield label="确认密码" id="userRePwd" onblur="checkrepwd(userPwd,this)"></s:textfield><div id="repwdinfo"></div>
<s:textfield label="电子邮箱" name="member.userEmail" id="userEmail" onblur="checkemail(this)"></s:textfield><div id="emailinfo"></div>
<s:submit></s:submit>
</s:form>Action 代码public String register(){
if (mServiceDao.addMember(member)) {
//this.getRequest().setAttribute("member", member);
System.out.println("OK");
return SUCCESS;
} else {
return INPUT;
}
}实现类代码:public boolean addMember(Member member) {
// TODO Auto-generated method stub
try {
this.getHibernateTemplate().save(member);
return true;
} catch (DataAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}Struts 配置<package name="member" extends="struts-default">
<action name="register" class="memberAction" method="register">
<result>/profile.jsp</result>
<result name="input">/register.jsp</result>
</action>
</package>代码都执行了,没有错误,但是数据没有添加到数据库中

解决方案 »

  1.   

    打印 member 看有数据没有
      

  2.   

    用户添加的member有数据,但是插入到数据库就没有东西!
      

  3.   

    你采用:post 提交试试!<s:form action="register.action" namespace="member" theme="simple" method="post">
      

  4.   


    提交后
    2010-11-6 9:55:08 org.apache.tomcat.util.http.Parameters processParameters
    警告: Parameters: Invalid chunk ignored.
    Hibernate: insert into member (userName, userPwd, userRealName, userEmail, userQuestion, userAnswer, userRegIp, userLoginIp, userRegTime, userLoginTime, userId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    但是数据库没有内容
      

  5.   

    要是数据进去了 检查下 你的 member 里面的 id 看你 id有值没! 
      

  6.   

    insert into member (userName, userPwd, userRealName, userEmail, userQuestion, userAnswer, userRegIp, userLoginIp, userRegTime, userLoginTime, userId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    你把这个数据把问号都用实际数据在数据库中测试下 看是不是 sql 问题!
    id 生成策略 是否为自动生成!
      

  7.   

    什么数据库?
    HSQLDB数据库就是正常现象了。
      

  8.   

    是那个userId 吗?你设置为主键呀!
      

  9.   


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    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
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    <!-- 【数据源】 -->
    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName"
    value="com.mysql.jdbc.Driver">
    </property>
    <property name="url"
    value="jdbc:mysql://localhost:3306/share">
    </property>
    <property name="username" value="root"></property>
    <property name="password" value="rgbgogj"></property>
    <property name="maxActive" value="100"></property>
    <property name="maxIdle" value="30"></property>
    <property name="maxWait" value="500"></property>
    <!-- 【是否自动执行事务】 -->
    <property name="defaultAutoCommit" value="false"></property>
    </bean>
    <!-- 【sessionFactory】 -->
    <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.MySQLDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>tk/accp/share/entity/Article.hbm.xml</value>
    <value>tk/accp/share/entity/Categories.hbm.xml</value>
    <value>tk/accp/share/entity/Comments.hbm.xml</value>
    <value>tk/accp/share/entity/Friend.hbm.xml</value>
    <value>tk/accp/share/entity/Member.hbm.xml</value>
    <value>tk/accp/share/entity/Memberinfo.hbm.xml</value>
    <value>tk/accp/share/entity/Message.hbm.xml</value>
    <value>tk/accp/share/entity/Searchword.hbm.xml</value>
    </list>
    </property>
    </bean>
    <!-- 【Dao】 -->
    <bean id="memberDao" class="tk.accp.share.dao.impl.MemberDaoImpl">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <!-- 【Service】 -->
    <bean id="memberServiceDao" class="tk.accp.share.service.impl.MemberServiceDaoImpl">
    <property name="MDao" ref="memberDao"></property>
    </bean>
    <!-- 【Action】 -->
    <bean id="memberAction" class="tk.accp.share.action.MemberAction" scope="prototype">
    <property name="MServiceDao" ref="memberServiceDao"></property>
    </bean>
    </beans>