jsp接收servlet傳值

ajax請求

$.ajax({    url: "<%=path%>/sso/servlet/IntegralEfficiencyServlet",    type: "post",    contentType: "application/x-www-form-urlencoded",    data: {"TOKEN": "<%=request.getParameter("token")%>"},    dataType: "text",success:     function(url){        console.log(url);        window.open("http://www.baidu.com");        return;    },    error:function(response){        console.log("error");    }});

$.post方式

$.post("<%=path%>/sso/servlet/IntegralEfficiencyServlet", {
    Action: "post",
    TOKEN: "<%=request.getParameter("token")%>",
    contentType: "application/x-www-form-urlencoded"
},
function(data, textStatus){
    alert(data + "," + textStatus);
});

servlet傳值

response.setContentType("application/x-www-form-urlencoded");
response.getWriter().print(url);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章