0
내 휴식 서비스에서 Json 데이터를 반환했지만 콘텐츠 헤더가 응답을 문자열로 표시합니다. 이 문제는 특히 ajax 함수 호출의 게시물 요청에서 발생합니까?응답 json 데이터
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">/script>
function authenticate(Source,Destination) {
$.ajax
({
type: 'POST',
url: 'REST/WebService/InsertFeeds',
dataType:'json',
//async: false,
data:{'Source': Source, 'Destination': Destination },
//headers: {
contentType: 'application/json',
//},
error:function()
{
alert("unsuccessfull");
},
success:function(feeds)
{
alert(feeds);
}
});
}
후 주석을 사용하여 데이터를 삽입에 대한
내 나머지 서비스 코드 :
@Path("/WebService")
public class LoginService
{
@POST
@Path("/InsertFeeds")
@Consumes("application/json")
@Produces("application/json")
public String messageFeed2(@FormParam("Source") String Source,@FormParam("Destination") String Destination)
{
String feeds = null;
try
{
String feedData=null;
ProjectManager projectManager= new ProjectManager();
feedData=projectManager.InsertFeeds(Source,Destination);
feeds=FeedTransformer.UserFeeding(feedData);//converts string in Json format using gson library
} catch (Exception e)
{
System.out.println("error");
}
return feeds;
}
}
현재 직면하고있는 문제는 무엇입니까? – Veera
Json은 문자열이므로 당연히 하나의 객체로 변환 할 때까지는 객체가 아닙니다. –
json 콘텐츠가 아닌 json 객체가 반환 된 데이터를 표시하는 방화범이 끌리는 이유는 무엇입니까? – shanky