首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

struts2 annotation回来json格式

2012-08-28 
struts2 annotation返回json格式package com.lvmama.back.sweb.knowledgeimport java.io.IOExceptionimp

struts2 annotation返回json格式

package com.lvmama.back.sweb.knowledge;import java.io.IOException;import java.util.List;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.ParentPackage;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;import com.lvmama.back.service.InfoService;import com.lvmama.back.sweb.BaseAction;import com.lvmama.common.info.po.InfoNormalQues;import com.lvmama.common.info.po.InfoQuesType;@ParentPackage("json-default")@Results({@Result(name = "list", location = "/WEB-INF/pages/back/knowledge/faq/list.jsp")})public class FAQAction extends  BaseAction{/** *  */private static final long serialVersionUID = -5531045656847240119L;private InfoService infoService;private List<InfoNormalQues> rows;private List<InfoQuesType> typeList;private String title;private Long type;private InfoNormalQues faq;private String result;private String userName;//private String rows;//private JSONArray jsonArray;@Action("/faq/toFaqList")public String toFaqList(){if (this.getSessionUser()!=null) {this.userName = this.getSessionUser().getLoginName();}this.typeList = infoService.selectByObjectType("INFO_QUES_NORMAL");return "list";}@Action("/faq/queryFaqList")public String queryFaqList(){//this.normalList = infoService.selectByTitleAndType(title, type);this.typeList = infoService.selectByObjectType("INFO_QUES_NORMAL");return "list";}@Action(value="/faq/queryjsonList",results=@Result(type="json",name="jsonlist",params={"includeProperties","rows.*"}))   public String queryjsonList(){this.rows = infoService.selectByTitleAndTypeForNormal(title, type);return "jsonlist";}@Action("/faq/saveFAQInfo")   public void saveOrUpdateFAQInfo() throws IOException{try{if (this.faq.getId()!=null&&!"".equals(this.faq.getId())) {infoService.updateFAQ(faq);} else {infoService.insertFAQ(this.faq);}this.getResponse().getWriter().write("{result:true}");}catch(Exception ex){ex.printStackTrace();this.getResponse().getWriter().write("{result:false}");}}@Action("/faq/remove") public void removeFAQ() throws IOException{try{infoService.removeFAQ(faq.getId());this.getResponse().getWriter().write("{result:true}");}catch(Exception ex){this.getResponse().getWriter().write("{result:false}");}}@Action(value="/faq/edit",results=@Result(type="json",name="edit",params={"includeProperties","faq.*"})) public String findFAQByPK(){this.faq = infoService.getFAQByPk(faq.getId());return "edit";}public void setInfoService(InfoService infoService) {this.infoService = infoService;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public Long getType() {return type;}public void setType(Long type) {this.type = type;}public List<InfoQuesType> getTypeList() {return typeList;}public void setTypeList(List<InfoQuesType> typeList) {this.typeList = typeList;}public List<InfoNormalQues> getRows() {return rows;}public void setRows(List<InfoNormalQues> rows) {this.rows = rows;}public InfoNormalQues getFaq() {return faq;}public void setFaq(InfoNormalQues faq) {this.faq = faq;}public String getResult() {return result;}public void setResult(String result) {this.result = result;}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}}
?

热点排行