百度问题

    jquery代码:
    var username = $('#username').val();
    var pwd = $('#pwd').val();
    var param ='{"username":"'+username+'","pwd":"'+pwd+'"}';
    $('#login').click(function(){
    alert(param);
    $.ajax({
    type:'post',
    url:'MyServlet',
    data:param,
    success:function(){}
    })
    })
    servlet代码:
    protected void doPost(HttpServletRequest request, HttpServletResponse resp)
    throws ServletException, IOException {
    String aa = request.getParameter("param");
    System.out.println(aa);
    }
    这里获取不到ajax传过来的param的值 调试为空的 为什么 求大神帮忙
解决方案
 data: {"orderId":orderId,"commant":commant},  
data: "orderId=" + orderId + "&commant=" + commant
解决方案二:
可能你地址给错了吧 是不是webxml配错了
解决方案三:
参数param 的格式不对:servlet getParameter方法接受不了json对象,
posted @ 2017-04-06 15:20  编程未来  阅读(201)  评论(0编辑  收藏  举报