Struts2如何返回json我的返回是空的,现在是SSH整合单个都试了,求解
喧嚣丶 2015-10-20 02:50:03 public class StudentAction extends ActionSupport{
private StudentService studentService;
//private List<Student> list;
//private Map<String, Object> m=new HashMap<String, Object>();
private String str;
public String queryAll() throws Exception {
//list = studentService.queryAll();
Map<String, Object> m=new HashMap<String, Object>();
m.put("name",654);
m.put("address",54654);
m.put("name",654);
str = JSONObject.fromObject(m).toString();
//JSONObject json = JSONObject.fromObject(list);
//result = json.toString();
//System.out.println("++++++++++++++++++++++++++++"+json);
return SUCCESS;
}
配置文件:
<package name="struts" namespace="/" extends="json-default">
<action name="studentAction" class="StudentAction">
<result name="success" type="json">
<param name="root">str</param>
</result>
</action>
</package>
json的包都有,不用说了