日期:2014-05-17  浏览次数:20585 次

struts2接受Ajax参数!
jquery Ajax参数形式:

var param1 = {"count":"102", "loginMemberId":"lyn"};

用我想在struts2 Action中通过Map<String, Object>类型接受。

我直接操作map.get("count"),就能取到102。

怎么实现,请高手帮忙!

------解决方案--------------------
{"map.count":"102", "map.loginMemberId":"lyn"};

------解决方案--------------------
那就SAMPLE下吧,
把JSON-LIB加到CLASSPATH里,然后ACTION里,
Java code

private String JSONRequest;
private JSONObject jo = new JSONObject();
    
    public void setJSONRequest(String JSONRequest){
        this.JSONRequest = JSONRequest;
    }
    
    public String getJSONRequest(){
        return JSONRequest;
    }
public String execute(){
        jo=JSONObject.fromObject(JSONRequest);
                jo.get("count");
                return SUCCESS;
}

------解决方案--------------------
spring mvc