本人做了个日志管理系统,可是在修改日志的时候信息不是在原来的基础上更改,而是另起了一行最为新信息显示出来了,不知道哪里错了,请高手帮忙,谢谢!
我保存日志信息的方法如下:
public ActionForward list(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){

List list = dailyManager.getDailies(new Daily());
request.setAttribute("daily", list);
return mapping.findForward("showdaily");

}
public ActionForward saveUpdate(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {

DailyForm dailyForm = (DailyForm) form;
String id = request.getParameter("dailyid");
Integer dailyid = Integer.parseInt(id);
Daily daily = dailyManager.getDaily(dailyid);
daily.setDailyid(dailyid);
daily.setTitle(dailyForm.getTitle());
daily.setContent(dailyForm.getContent());
daily.setPosttime(dailyForm.getPosttime());
daily.setPoster(dailyForm.getPoster());
dailyManager.saveDaily(daily);
return list(mapping,form,request,response);
}
jsp页面如下:
<%@ page language="java" pageEncoding="GBK"%>
<%@page import="com.daily.model.*" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %><%
Users User = (Users) session.getAttribute("USER");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>浏览日志 管理日志</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body>
  <h2 align="center"><font color="blue">浏览日志 管理日志</font></h2>
    <div align="center"> <table align="center" bgcolor="pink" border="1px" cellspacing="0" cellpadding="10" width="600" height="120">
<tr>
<th>
<html:link action="toAddDaily">添加日志</html:link>
</th>
<td></td>
<td></td>
</tr>
<tr bgcolor="yellow">
<th>
日志标题
</th>
<th>
日志内容
</th>
<th>
填报时间
</th>
<th>
报送人
</th>
<th>
操作
</th>
</tr>
<logic:iterate id="daily" name="daily">
<tr bgColor=#E4E8EF>
<td>
<bean:write name="daily" property="title"/>
</td>
<td>
<bean:write name="daily" property="content"/>
</td>
                    <td>
                        <bean:write name="daily" property="posttime"/>
                    </td>
                    <td>
                        <bean:write name="daily" property="poster"/>
                    </td>
<td>
<table align="center">
<tr>
<th>
<html:link action="/daily?method=update&dailyid=${daily.dailyid}">修改</html:link>
</th>
<th>
<html:link action="/daily?method=delete&dailyid=${daily.dailyid}">删除</html:link>
</th>
<th>

</th>
</tr>
</table>
</td>
</tr>
</logic:iterate>
</table>

</div>
<br>
<br>
<div align="center">
<html:link action="toMain">返回主页</html:link>
</div>

  </body>
</html:html>