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">&nbsp;&nbsp;&nbsp;
<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" >
  <% } %>
&nbsp;&nbsp;
 </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>&nbsp;</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也无法得到,不知什么原因,
快三天了,也没有搞懂原因,请各位大虾救救命啊!

解决方案 »

  1.   

    //  alert("editreplyid="+editreplyid);
    这里注释打开后,editreplyid=多少?
    再次,我不明白楼主为什么要这样传递参数。
    你直接在页面做个editreplyid的hidden域通过form传递表单不更好吗?
    比如<input type="hidden" name="editreplyid" value="<%=yourValue%>">
      

  2.   

    怎么我感觉和我昨天那样像呢。我也是刚刚学struts。
    我是我得原因是因为在敲打两个.xml要不打错字母,要么就是少打。把这些改好了。就能用了。
    高手给我提示,让我多看tomcat得启动文件。那里可以找到能多错误出来。
    发一下感慨~呵呵~
      

  3.   

    刚开始的时候。在写程序的过程难免会漏写、多写、错写等等
    有一次我的SQL语句在用到插入时。多写了一个空格。害得我
    苦脑了几天.这样的事在刚踏入程序邻域是必修课。
    慢慢的做久了。吃了苦头,就会明白做事要细心,不然的话
    会让自己在那些小小的错误上苦不堪言.
      

  4.   

    myform.action="editreply.do?editreplyid="+editreplyid;   
           document.myform.submit();
    这样写是有问题的,处理第二句时,只提交input域,第一句是不起作用的,你可以把 editreplyid="+editreplyid;   写成<input type=hidden name=editreplyid value= >;
      

  5.   

    这样提交应该没问题
    几点注意
    1、变量名大小写对应
    2、变量的值,有没有值,有没有特殊字符
    3、form的method,post?get?
      

  6.   

    感谢楼上各位的建议能及提供的思路,用隐藏域是个解决办法,不过我现在解决了这个困扰我三天的问题,原来把<form name="myform">改成<form name="myform" method="post">就可以了,怪我自己太粗心了,但我奇怪的是我以前也这样用过传参数的方法,也没有加method="post"这句,同样也参数传到下一页面了,搞不懂!