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