我用Struts+Hibernate做了一个新闻发布系统,其中新闻上就有一个点击率,可是每次
刷新过后次数都刷信不过来!
请各位高手指点!!!
刷新过后次数都刷信不过来!
请各位高手指点!!!
解决方案 »
- 如何用myeclipse 开发jquery
- SSH调用DispatchAction中的方法
- 正则验证 -10到120
- jsp怎样实现双列分页呢?高手指点
- Struts+Spring+Hibernate框架若干问题
- 大家进来帮帮我吧.高分求助 无限多级分类的实现方法.我保证已经google和baidu完毕.可还是不解~~
- POIFSFileSystem读取Excel 急 急
- 下面控制中文乱码de一段代码可以加入jsp中直接使用么(帮帮看看,谢谢)
- 关于html页面数据提取探讨
- 如何在Windows 9x环境中配置Apache + Tomcat.JSP
- richfaces的suggestionBox
- 关于打开/admin/index.jsp 找不到useBean的问题
新闻读取用:
public List findAll() {
log.debug("finding all Zb instances");
try {
String queryString = "FROM Zb order by id desc";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
新闻点击率的更新用:
public void updatecount(int id)
{
String hql="update Zb as a set a.count=a.count+1 where a.id=?";
Query query=getSession().createQuery(hql);
query.setInteger(0,id);
query.executeUpdate();
getSession().beginTransaction().commit();
}
Action中通过request.setAttribute("list",list)将读出的数据保存到request中
数据显示代码:
<logic:present name="list" scope="request">
<td width="117" height="35"><span style="font-weight: bold">日期</span>:${list.date}</td>
<td width="122"><span style="font-weight: bold">作者</span>:${list.user1}</td>
<td width="389"><span style="font-weight: bold">点击:${list.count}</span></td>
<td align="center" height="34" colspan="5"><span style="font-size: 16px">${list.title}</span></td>
</logic:present>
public List findAll() {
log.debug("finding all Zb instances");
try {
String queryString = "FROM Zb order by id desc";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
日期:${list.date}
作者:${list.user1}
点击:${list.count}
标题:${list.title}
</logic:present>
这样读取的其他数据没问题的,就是读出的数据好像还是上次的数据!!!!
你在session.creqtequery("")时候要清空缓存区