foreverxunyc
forever_cherry
2014-04-18 12:01
采纳率: 33.3%
浏览 629
已采纳

jsp通过js跳转到servlet后的传值问题

* 商家名称:
* 商家电话:
* 商家海报: 本地远程:
* 商家地址:
* 验证手机: &nbsp &nbsp添加
&nbsp &nbsp
//验证填入值不为空 function checkEmpty(){ var name = document.getElementById("merchantName").value; var call = document.getElementById("merchantCall").value; var picture = document.getElementById("UploadButton").value; var adress = document.getElementById("merchantAdd").value; var validate = document.getElementById("validatetCall").value; if(name==""||call==""||picture==""||adress==""||validate==""){ alert("请您填写所需要的信息"); } else{ // 跳转到AddMerchantServlet中 document.merchantForm.action = "/discountCoupon/AddMerchant"; document.merchantForm.submit(); } }

@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

    //从addMerchant.jsp中取得数据
    String merchantName =(String) request.getParameter("merchantName");

// String merchantCall = request.getParameter("merchantCall");
// String picture = request.getParameter("picture");
// String merchantAdd = request.getParameter("merchantAdd");
// String validateCall = request.getParameter("validateCall");
if(merchantName!=null)
System.out.println(merchantName);
else
System.out.println("数据没得到");}

得不到数据

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新