Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区 » J2EE SDK  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 求助:Struts问题
guomi2004





发贴: 1
积分: 0
于 2008-03-19 20:10 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
修改数量
页面:

<form action="/commerce/cart.do?method=update" method="get">
  <table>
    <tr>
     <td>数量</td>    
    </tr>
    
<logic:iterate id="cartItem" scope="session" name="Sessio nContainer" property="cart.items">
<tr>
<td><input type="text" name="qty_<bean:write name="cartItem" property="id"/>" value="<bean:write name="cartItem" property="quantity"/>">
</td>
</tr>
</logic:iterate>
<tr>
<td colspan="1" align="center">
<html:submit></html:submit>
</td>
</tr>
</table>
</form>

action:

public class GetItemDetailActions extends CommerceDispatchAction {
public ActionForward update(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response) {
    // TODO Auto-generated method stub
    updateQuantity(request);
    return mapping.findForward("success");
  }
  
  private void updateQuantity(HttpServletRequest request){
    SessionContainer sessionContainer=this.getSessionContainer(request);
    Enumeration enum1=request.getParameterNames();
    while(enum1.hasMoreElements()){
      String ids=(String)enum1.nextElement();      
      if(ids.startsWith("qty_")){
        String qtyString =request.getParameter(ids.substring(4,ids.length()));        
        sessionContainer.getCart().updateQuantity(Integer.parseInt(ids), Integer.parseInt(qtyString));  
      }
    }
  }
}

struts-config。xml

<action
  path="/cart"
   scope="request"
   type="commerce.action.GetItemDetailActions"
   validate="false"
   parameter="method" >
    <forward name="success" path="/commerce/cart.jsp"></forward>
</action>

异常:
javax.servlet.ServletException: Request[/cart] does not contain handler parameter named 'method'. This may be caused by whitespace in the label text.
  org.apache.struts.actions.DispatchAction.unspecified(DispatchAction.java:222)
  org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:256)
  org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
  org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
  org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
  org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
  org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



作者 Re:求助:Struts问题 [Re:guomi2004]
hy806806





发贴: 1
积分: 0
于 2008-07-28 16:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
does not contain handler parameter named 'method'. This may be caused by whitespace in the label text

////////////////
你/card.do?后面为什么要加method=update? 难道你想传参数??呵呵



作者 Re:求助:Struts问题 [Re:guomi2004]
andy_wang_5





发贴: 101
积分: 14
于 2008-07-30 09:32 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
commerce/cart.do?method=update 是可以的.不过要从DispatchAction继承.


鹰行折翼 再盼凌云
作者 Re:求助:Struts问题 [Re:guomi2004]
tiger_hlq





发贴: 9
积分: 0
于 2008-09-12 10:46 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
'method'这个参数传递可以在action中传递, 或是在struts-config.xml中传递.
在JSP中是不对的



作者 Re:求助:Struts问题 [Re:guomi2004]
nihaolaogao





发贴: 8
积分: 0
于 2008-11-21 23:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在Form后的action中是不能加参数的.
你可写一个超连接,或写一个js.应该可以传过去了.比如
document.getDocumentById("Form").action="/commerce/cart.do?method=update";
document.getDocumentById("Form").submit();




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923