edittopic.jsp的主要代码如下:
<html:html>
<title>编辑新话题</title>
<script language="javascript">
function edit(){
var editreplyid ='<%=checkNull(request.getParameter("editreplyid"))%>';
if(editreplyid==""||editreplyid==null) {
// alert("edittopicid="+edittopicid);
myform.action="edittopic.do";
document.myform.submit();
}
else
{
// alert("editreplyid="+editreplyid);
myform.action="editreply.do?editreplyid="+editreplyid;
document.myform.submit();
}
}
</script>
</head>
<%
String edittopicid="";
String editreplyid="";
try {
edittopicid=(String)session.getAttribute("topicid");
editreplyid=checkNull(request.getParameter("editreplyid"));
}
catch(java.lang.NumberFormatException ex)
{ }
%>
<body>
<html:errors/>
<%
if(editreplyid==""){
request.setAttribute("edittopic",forumbean.edittopic(edittopicid));
}
else {
request.setAttribute("edittopic",forumbean.editreply(editreplyid));
}
%>
<form name="myform">
<logic:iterate id="edit" name="edittopic" scope="request">
<table height=330 cellSpacing=0 borderColorDark=#008080 cellPadding=0 width=765
borderColorLight=#ffffff border=1>
<tr><td width="81" height="52" align="center">主题标题</td>
<td width="678">
<input type="text" name="edittitle" height="18" size="40" value='<bean:write name="edit" property="edittitle"/>'></td></tr>
<tr><td height="58" align="center">当前心情</td>
<td>
<% for(int i=1;i<10;i++){ %>
<input type="radio" name="editmood" value="0<%=i%>" class="style1" >
<img src="images/mood/0<%=i%>.gif" >
<% } %>
</td>
</tr>
<tr><td height="218" align="center">内容</td>
<td><textarea name="editcontent" rows=16 cols=95><bean:write name="edit" property="editcontent"/></textarea></td></tr>
<tr><td> </td>
<td align="center"><input type="button" name="publish" value="重新编辑" onclick="edit()"></td></tr>
</table>
</logic:iterate>
</form>
</body>
</html:html> EditreplyAction主要代码如下:
public class EditreplyAction extends Action {
//更新回复贴子
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
throws Exception {
String editreplyid=request.getParameter("editreplyid");
// System.out.println("editreplyid="+editreplyid);
EditForm editform=(EditForm)form;
String edittitle=editform.getEdittitle();
String editmood=editform.getEditmood();
String editcontent=editform.getEditcontent();
String editip=request.getRemoteAddr();
java.util.Date now=new java.util.Date();
String currenttime=new Timestamp(now.getTime()).toString();//获取系统当前时间
ForumBean service=new ForumBean();
try{
service.updatereply(editreplyid,edittitle,editmood,editcontent,editip,currenttime);
return (mapping.findForward("reply"));
}
catch(Exception de){
return(new ActionForward(mapping.getInput()));
}
}
}
struts-config.xml主要代码如下
<action path="/editreply"
type="action.EditreplyAction"
name="editform"
scope="request"
input="/edittopic.jsp"
validate="true">
<forward name="reply" path="/showlist.jsp"/>
</action>其中editform中封装了表单字段的数据,现在的问题是提交表单后可以把表单数据传递到action中,却无法把
"editreply.do?editreplyid="+editreplyid"中的editreplyid值传到action中,在下一页面的url中就连参数名editreplyid也无法得到,不知什么原因,
快三天了,也没有搞懂原因,请各位大虾救救命啊!
解决方案 »
- --filter中把请求参数用base64加密解密怎么做?
- 如何动态添加select的option.
- 急...上转功能,更改file默认的按钮后,上转提示找不到文件。
- 页面中,鼠标移动时CPU占用100%?
- sqlserver 分组查询
- jsp 连 sql2005一直出这个问题怎么办
- 急!!!在线等 java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]System Exception: Socket closed
- 两个表关联,A表插入数据的同时,B表也增加一条数据,外键关联,如何实现?
- 菜鸟的小问题,org.apache.myfaces.custom.fileupload.UploadedFile这个包去哪里找?
- 怎么连接两台计算机?
- 怎么我的问题没人回答
- jsp传参数的时候,参数中包含单引号''会传不过去么????
这里注释打开后,editreplyid=多少?
再次,我不明白楼主为什么要这样传递参数。
你直接在页面做个editreplyid的hidden域通过form传递表单不更好吗?
比如<input type="hidden" name="editreplyid" value="<%=yourValue%>">
我是我得原因是因为在敲打两个.xml要不打错字母,要么就是少打。把这些改好了。就能用了。
高手给我提示,让我多看tomcat得启动文件。那里可以找到能多错误出来。
发一下感慨~呵呵~
有一次我的SQL语句在用到插入时。多写了一个空格。害得我
苦脑了几天.这样的事在刚踏入程序邻域是必修课。
慢慢的做久了。吃了苦头,就会明白做事要细心,不然的话
会让自己在那些小小的错误上苦不堪言.
document.myform.submit();
这样写是有问题的,处理第二句时,只提交input域,第一句是不起作用的,你可以把 editreplyid="+editreplyid; 写成<input type=hidden name=editreplyid value= >;
几点注意
1、变量名大小写对应
2、变量的值,有没有值,有没有特殊字符
3、form的method,post?get?