2014-07-08 2 views
3

나는이 같은 JSON 개체를 구축 스트럿츠에 아약스에서 게시핸들 JSON 배열은 1.3

sendData = function() { 
    $.ajax({ 
    url :'<html:rewrite action="/sendData"/>', 
    type: "POST", 
    dataType: 'json', 
    contentType: "application/json; charset=utf-8", 
    data : {"list":list.item}, 
    success:function(data) { 
     alert(data); 
    }, 
    error: function(jqXHR, textStatus, errorThrown) { 
     alert("Error");  
    } 
    }); 
} 

가 어떻게 내 행동에 검색 할 수 JSONArray/JSONObject 그리고 처리할까요? 나는 이것을 시도했다 :

public ActionForward execute(ActionMapping mapping, ActionForm form, 
     HttpServletRequest request, HttpServletResponse response) 
     throws Exception { 
     String list = request.getParameter("list"); //null, I supposed to find a string formatted like json 
     return null; 
} 

심지어 GSON 라이브러리도 허용된다!

답변

0

매개 변수로 보낼 때 개체를 문자열로 변환하면 상당한 개선이 있습니다.

data : {list: JSON.stringify(list.item)}