52,797
社区成员
发帖
与我相关
我的任务
分享
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;
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;
}
}
<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>