rt.
struts后端返回的数据是一个bean
- Java code
private int id; private String content; private String title; private String p_time; private String author; private String c_id; private String imgurl; private String hot;
struts返回的代码是:
- Java code
package cn.qin.Actions; import org.apache.struts2.json.annotations.JSON; import org.json.JSONException; import net.sf.json.JSONArray; import cn.qin.DAO.impl.newsOperateDAOimpl; import cn.qin.Models.NEWS; import cn.qin.Services.newsServices; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; public class showNewsAction extends ActionSupport { NEWS news = new NEWS(); newsServices newsservices = new newsServices(); JSONArray JSON = new JSONArray(); String c_id; public String execute() { return Action.SUCCESS; } public String getC_id() { return c_id; } public void setC_id(String c_id) { this.c_id = c_id; } @JSON(name="news") public JSONArray getJSON() throws JSONException { return newsservices.showNews(this.getC_id()); } public void setJSON(JSONArray jSON) { this.JSON = jSON; } }
struts的配置文件是这样的,
- XML code
<package name="show" namespace="/" extends="json-default"> <action name="showNewsAction" class="cn.qin.Actions.showNewsAction" > <result type="json"> <param name="includeProperties">news/.id,news/.title,news/.p_time</param> </result> </action> </package>
可是在前台进行测试的时候,一些不希望返回的数据还是返回了比如说,content,这是文章内容,一本会很长,所以这个不用返回,我的配置错了吗,请高手指点
------解决方案--------------------
不需要返回的,后台不打印不就可以了?