안녕하세요 저지에서 구현 된 Restful WS에 json 데이터를 게시하려고합니다. jquery-ajax를 통해 데이터를 게시하고 있습니다. HTTP Status-415가 지원되지 않는 미디어 유형을 가져 오는 이유는 무엇입니까? 고맙습니다. HTTP 상태 415 - JREERY에서 AJAX 호출에 대해 지원되지 않는 미디어 유형이 JERSEY로 구현 된 편안한 WS
//post method handler
@Path("/newentry")
public class NewEntry {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response newEntry(String data) {
//doStuff
}
}
// ajax call
$.ajax({
url: "http://localhost:8080/FirstRestWebService/rest/newentry",
type: "post",
data: formToJSON(),
dataType : "json",
success: function(data){
alert("success");
},
error:function(jqXHR, textStatus, errorThrown) {
alert("failure");
}
});
function formToJSON() {
return JSON.stringify({
"name": $("input#emp_name").val(),
...
"username": $('input#username').val(),
"password": $('input#password').val()
});
Click here for screenshot of firebug description Click here for screenshot of firebug description
나는 뉴저지 클라이언트에 의해 성공적으로 WS를 테스트 할 수 있었다. 위의 AJAX 호출에서 잘못된 점은 무엇입니까? 고맙습니다.
contentType: "application/json"
대단히 고마워. – mik