问题1
通过URL得到数据,字符串形式,String str ={"weatherinfo":{"city":"北海","city_en":"beihai","date_y":"2013年1月23日"}}
然后通过JSONObject类还是JSONArray类进行转换?
在java代码中,使用json.getString如何得到city 和city_en等的值。谢谢问题2
struts2 *_* 通配符能交给spring管理吗?项目的struts2是使用*_*的通配符配置的。如果交给spring管理,必须在class中配置别名,但这样的*_*如何在spring对应? 

解决方案 »

  1.   

    问题1,对象的都用JSONObject;String str ="{\"weatherinfo\":{\"city"\:\"北海\",\"city_en\":\"beihai\",\"date_y\":\"2013年1月23日\"}};
    JSONObject jsonObject=JSONObject.fromObject(str);
    JSONObject weatherInfoObj=jsonObject.getObject("weatherinfo");//获得weatherinfo的属性值它是一个JSONObject
    String city=weatherInfoObj.getString("city");//city的属性值
    String city_en=weatherInfoObj.getString("city_en");问题2:struts2的通配符是访问的action的名称不是类名,struts2交给spring管理的是action的类跟通配符不影响
      

  2.   

    第一个问题  JsonObject  接收
    第二个问题  通配符的同样可以交给spring执行(基于struts.xml配置)