AJAX 요청에서 POST 데이터를 받아들이는 서블릿을 작성 중입니다. 여기 String string = request.getParameter ("data") is null
내가 클라이언트에서 보내는 코드입니다 :$.ajax({
type: "POST",
url: "urlservlet",
data: "{type:'" + "country" +
"', country:'" + $('#country').val() +
"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
}
그리고 이것은 서블릿 코드 :
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
string test = request.getParameter("type");
}
그러나 것은 항상 null에 동일한 종류를 얻을 수있다. 나는 이유를 모른다.
친절히 도와주세요.
당신의 제목은'getP (data)'라고 말하고 코드는'getP (type)'라고합니다. 실제 문제는 무엇입니까? – SudoRahul