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; } }?
详细解决方案
struts2 annotation回来json格式
热度:108 发布时间:2012-08-28 12:37:01.0
相关解决方案
- struts2.xml的action中的result报错,该怎么处理
- (Struts2+JSON+Ajax) XMLHttpRequest ==500如何解决
- struts2 对象属性流入不进去, 报错:target is null for setProperty(null, "x" [Ljava.lang.Stri
- json 解析有关问题
- Struts2 <select>上拉框 回显有关问题
- struts2 添加和修改怎么在一个jsp页面实现
- struts2 查询输出的有关问题
- 多对多双向联系关系(annotation&xml)
- 零配置的有关问题(struts2+Hibernate)
- struts2 神奇有关问题,太神奇了!
- 一对多(多对一)双向联系关系(annotation&xml)
- struts2 的<s:iterator>标签展示未完全初始化的数组出现奇怪的有关问题
- struts2 文件下传有关问题
- struts2+ajax请求失败,帮忙看一上
- struts2-json中诠注@JSON(deserialize=false)是什么用?不是阻止JSON反序列化成JAVA对象吗?求解
- struts2 循环累加属性值有关问题
- struts2,hibernate,spring3 常用框架的API CHM版本,该怎么处理
- struts2 将jsp回到到另一个jsp中
- struts2 提交表单不能跳转页面有关问题!action已经执行,但是不能跳转到指定的页面
- struts2,hibernate,spring3 惯用框架的API CHM版本
- Struts2+Spring+JPA+FREEMARKER 登录程序异常
- struts2+Hibernate一个很奇怪的现象,该如何解决
- struts2 action中部分语句被直接跳过不执行. 请教这会是什么原因
- struts2+iReport 子表格 急需高手解决,已经困惑三天了!
- import cn.luxh.struts2.entity.Novel 急需的jar包是哪个
- struts2 hibernate 分页有关问题
- struts2 + spring 整合有关问题
- 请教哪里可以上到 struts2-json-plugin-2.1.8的源文件
- struts2+freemarker中文参数乱码有关问题
- struts2 exception,该怎么解决