关于Stuts 的result type=Json的问题
struts2吧
全部回复
仅看楼主
level 1
1035128317 楼主
最近在看一位前辈代码,struts代码是这样的
<action name="com_paraAction" class="com.aw.action.Com_paraAction">
<result type="json" />
</action>
然后在com_paraAction类里的execute方法是这样写的,
public String execute() throws Exception {
HttpServletResponse response=ServletActionContext.getResponse();
HttpServletRequest request=ServletActionContext.getRequest();
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String type=request.getParameter("param");
System.out.println(type);
this.setCom_para(new Com_paraBIZ().get_para(type));
System.out.println("com_para="+com_para.getContent());
System.out.println("completed");
return SUCCESS;
}
我不懂返回的Json数据是哪个变量的,有没有大佬可以指教下?
2017年10月13日 14点10分 1
level 3
result元素 的type属性值有json吗?
2018年01月09日 14点01分 2
level 1
json 应该是自定义的结果类型,struts2 中结果默认结果类型没有json,json返回的应该是数据而不是整个页面,具体的你应该查看实现了json Result的哪个自定义结果类型的类。这个类里面应该包含了写json输出的流
2018年03月21日 07点03分 3
1