本人做了个日志管理系统,可是在修改日志的时候信息不是在原来的基础上更改,而是另起了一行最为新信息显示出来了,不知道哪里错了,请高手帮忙,谢谢!
我保存日志信息的方法如下:
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>
我保存日志信息的方法如下:
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>
解决方案 »
- 登录页面输入错误后会在URL地址中持续增加login字段
- 高分求救,webservice接口get方式请求怎么实现?
- javascript控制上传图片的大小
- Web Project 编译执行后出现 The requested resource (/telephone/search.jsp) is not available.什么意思?是有哪些原因引起的。
- 利用URL1+(**)+URL2可以跳转到URL2
- eclipse做jsp程序时候怎么单步调试阿???
- 欢迎石家庄的java朋友加入改群 33600835 互相学习。。。
- 怎样用session来限制用户对页面的访问?
- Strust中*.properties的位置
- 求JSP中实现MD5加密的函数.
- 求解,struts2.0中<s:if> 标签疑问。。。。
- weblogic部署不支持jstl版本的问题
这个方法 里面你看下输出SQL 是不是执行了update 还是每次都是insert
二是你页面的原因吧 自己好好检查下