当前位置:编程学习 > JAVA >>

初学SSH2做一个简单的论坛回帖功能,没报错但数据库信息没增加..

这是Action
public String execute() throws Exception {
Date now=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time=sdf.format(now).toString();
replays.setPostTime(Timestamp.valueOf(time));
replays.setOpposeCount(0);
replays.setUsers((Users)ActionContext.getContext().getSession().get("users"));


rbiz.replay(replays);
return super.input();
}
这是struts.xml

<action name="ReplaysAction" class="Replay">
<result name="input" type="redirect" >TopicDetailsAction?id=${topicId}</result>

</action>
这是jsp页面
<div id="replay" style="display:none">
    <s:form action="ReplaysAction" method="post">
  
     <input type="text" name="replays.topicId" value="#request.tid" style="display:none "/>
   
    <table style="width:600; ">
    <tr><td colspan="2"   height="20px" style="border-right-style: none;border-bottom-style: none;"><img src="images/replay.jpg"/> <span style="font-size:15;font-family:幼圆;font-weight:bold"> 发表回复及评论 </span><br/><br/><span>请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论 。<a href="#" onclick="cancel()">取消回复 </a> </span> </td> </tr>
    <tr>
    <td style="border-right-style: none;border-bottom-style: none;border-top-style: none">
    <textarea  name="replays.replayContent" rows="7" cols="100" style="overflow:auto;border:1px solid red "></textarea>
   
   </td>
  
   <td style="border-right-style: none;"> <s:submit value="回   复" onclick="CKreplay()" ></s:submit> </td>
        </tr>

    </table>
   </s:form>
   
    </div>
程序运行正常,能正确跳转到指定的页面,可没成功,又没有报异常,这是什么回事 还请高手帮忙给分析分析... --------------------编程问答-------------------- 有commit么。。。 --------------------编程问答--------------------
引用 1 楼  的回复:
有commit么。。。

这是Dao:
public void PostTopic(Topics topics) {

getHibernateTemplate().save(topics);
getHibernateTemplate().flush();

} --------------------编程问答--------------------
引用 2 楼  的回复:
引用 1 楼  的回复:

有commit么。。。

这是Dao:
public void PostTopic(Topics topics) {

getHibernateTemplate().save(topics);
getHibernateTemplate().flush();

}

贴错了
是:
public void replay(Replays replays) {
super.getHibernateTemplate().save(replays);
super.getHibernateTemplate().flush();

} --------------------编程问答-------------------- 首先还是先定位问题大概的位置吧,比如前后台,Action,Service,Dao,可以在每一层写一些测试的代码,一上来就贴代码,估计没几个能看明白

QQ:79174715② 小龙在线(只限技术讨论和项目交流,非诚勿扰) --------------------编程问答-------------------- 那就是对应的action没有执行到 或者执行了一个空的方法? --------------------编程问答-------------------- 可以再biz 和dao中分别打印,最好将sql语句记日志
--------------------编程问答-------------------- 在配置hibernate.xml 中要配置commit 为true ,才行 --------------------编程问答-------------------- 谢谢各位!特别是 架构师的 提示 我记住了!一年级的水平急待提高啊! --------------------编程问答-------------------- 在myeclipse上加断电调试,找找看就知道了 --------------------编程问答-------------------- 嫩上传个源码文件吗
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,