下面是我的问题描述
1:我在action中是这样写的public class MofifyShopCartAction extends DispatchAction {
public ActionForward MofifyShopCartById(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
ShopCartForm scf = (ShopCartForm) form;
int pro_amount = scf.getProductAmount();
2:我在jsp中 <input type="text" name="productAmount" size="2" value="<%=ol.getAmount()%>"/> ,
<a href="modifyshopCartActionById.do?method=MofifyShopCartById&id=<%=ol.getProduct().getProductid()%>">修改</a>我想将text文本框中修改后的数据通过form在action中打印出来,为什么 int pro_amount = scf.getProductAmount();总是为0
3:备注:我在ShopCartForm中有productAmount这个属性,且在struts中配置好,
jsp中也在<form></form>中,我想通过 <a href="modifyshopCartActionById.do?method=MofifyShopCartById&id=<%=ol.getProduct().getProductid()%>">修改</a>超链接实现提交表单数据并且要传递id这个参数,请问各位高手,应该怎么实现
1:我在action中是这样写的public class MofifyShopCartAction extends DispatchAction {
public ActionForward MofifyShopCartById(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
ShopCartForm scf = (ShopCartForm) form;
int pro_amount = scf.getProductAmount();
2:我在jsp中 <input type="text" name="productAmount" size="2" value="<%=ol.getAmount()%>"/> ,
<a href="modifyshopCartActionById.do?method=MofifyShopCartById&id=<%=ol.getProduct().getProductid()%>">修改</a>我想将text文本框中修改后的数据通过form在action中打印出来,为什么 int pro_amount = scf.getProductAmount();总是为0
3:备注:我在ShopCartForm中有productAmount这个属性,且在struts中配置好,
jsp中也在<form></form>中,我想通过 <a href="modifyshopCartActionById.do?method=MofifyShopCartById&id=<%=ol.getProduct().getProductid()%>">修改</a>超链接实现提交表单数据并且要传递id这个参数,请问各位高手,应该怎么实现
你是通过超链接提交的还是表单提交的,超链接提交的话,form中只能得到一个id,是得不到其他参数的2<a href="modifyshopCartActionById.do?method=MofifyShopCartById&id=<%=ol.getProduct().getProductid()%>">
在MofifyShopCartById方法中,可以这样得到 String id=scf.getProductid()
你要用js函数:
function submitModify(){
document.getElementById(‘modifyshopCartForm’).submit()”
}<form name="modifyshopCartForm" actin="modifyshopCartActionById.do?method=MofifyShopCartById" id="modifyshopCartForm" method="post"/>
<input type="text" name="productAmount" size="2" value="<%=ol.getAmount()%>"/>
<input type="hidden" name="id" value="=<%=ol.getProduct().getProductid()%>
"/> <a href="#" onclick="submitModify();">修改</a>或者就直接
<input type="submit" value="修改"/>
</form>
1:<form action="" method="">
</form>
上面的form表单提交时,会把form的<input type="text">值传递过去
2:超链接 传递,只能是 url?参数名1=参数值1&参数名2=参数值2,它不能把form中的
<input type="text">传递,它们是不同的,甚至没有关系的。