精华帖 (8) :: 良好帖 (2) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2013-07-14
文档逻辑结构很清晰,相当的通熟易懂,期待进一步的更新。
|
|
返回顶楼 | |
发表时间:2013-07-29
rop框架能加入服务器推技术吗?
|
|
返回顶楼 | |
发表时间:2013-08-01
请问下作者 能支持返回xml中包含List吗? 貌似返回List用注解不行。
/** * * 违章记录Request * * @author hncdyj123@163.com */ @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "response") public class GetIllegalRecordResponse { /** 返回码 **/ private String resultcode; /** 返回消息 **/ private String reason; /** 省份 **/ private String province; /** 城市 **/ private String city; /** 车牌 **/ private String hphm; /** 号牌种类 **/ private String hpzl; /** 违章记录详情 **/ @XmlJavaTypeAdapter(ListAdapter.class) private List<?> list; public String getResultcode() { return resultcode; } public void setResultcode(String resultcode) { this.resultcode = resultcode; } public String getReason() { return reason; } public void setReason(String reason) { this.reason = reason; } public String getProvince() { return province; } public void setProvince(String province) { this.province = province; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getHphm() { return hphm; } public void setHphm(String hphm) { this.hphm = hphm; } public String getHpzl() { return hpzl; } public void setHpzl(String hpzl) { this.hpzl = hpzl; } public List<?> getList() { return list; } public void setList(List<?> list) { this.list = list; } } 然后我List中放入的类 /** * * 违章详细 * * @author hncdyj123@163.com */ public class IllegalRecordDetail extends BasePojo { /** * serialVersionUID */ private static final long serialVersionUID = -739130308826537426L; /** 日期 **/ private String date; /** 区域 **/ private String area; /** 违章行为 **/ private String act; /** 违章代码 **/ private String code; /** 扣分 **/ private String fen; /** 罚款 **/ private String money; @XmlTransient private String frequency; @XmlTransient private String isparking; public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getArea() { return area; } public void setArea(String area) { this.area = area; } public String getAct() { return act; } public void setAct(String act) { this.act = act; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getFen() { return fen; } public void setFen(String fen) { this.fen = fen; } public String getMoney() { return money; } public void setMoney(String money) { this.money = money; } public String getFrequency() { return frequency; } public void setFrequency(String frequency) { this.frequency = frequency; } public String getIsparking() { return isparking; } public void setIsparking(String isparking) { this.isparking = isparking; } } 转换xml的结果 求指教返回List,谢谢! |
|
返回顶楼 | |
发表时间:2013-08-01
wqp310520 写道 rop框架能加入服务器推技术吗?
不行哦 是基于HTTP的 |
|
返回顶楼 | |
发表时间:2013-08-01
hncdyj 写道 请问下作者 能支持返回xml中包含List吗? 貌似返回List用注解不行。
/** * * 违章记录Request * * @author hncdyj123@163.com */ @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "response") public class GetIllegalRecordResponse { ... /** 车牌 **/ private String hphm; /** 号牌种类 **/ private String hpzl; /** 违章记录详情 **/ @XmlJavaTypeAdapter(ListAdapter.class) private List<?> list; public String getResultcode() { return resultcode; } ... } ... 转换xml的结果 求指教返回List,谢谢! 是可以的,我自己的系统就拥有很多List的,请看正确的注解: @XmlElementWrapper(name = "allotItems") @XmlElement(name = "allotItem") private List<ReceiveAllotItemRop> receiveAllotItemRops; |
|
返回顶楼 | |
发表时间:2013-08-02
楼主 你好!
按照你说的 我将代码改成了如下: package com.glsx.gop.wzcx.response; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; /** * * 违章记录Request * * @author hncdyj123@163.com */ @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "response") public class GetIllegalRecordResponse { /** 返回码 **/ private String resultcode; /** 返回消息 **/ private String reason; /** 省份 **/ private String province; /** 城市 **/ private String city; /** 车牌 **/ private String hphm; /** 号牌种类 **/ private String hpzl; /** 违章记录详情 **/ @XmlElementWrapper(name = "lists") @XmlElement(name = "list") private List<?> list; public String getResultcode() { return resultcode; } public void setResultcode(String resultcode) { this.resultcode = resultcode; } public String getReason() { return reason; } public void setReason(String reason) { this.reason = reason; } public String getProvince() { return province; } public void setProvince(String province) { this.province = province; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getHphm() { return hphm; } public void setHphm(String hphm) { this.hphm = hphm; } public String getHpzl() { return hpzl; } public void setHpzl(String hpzl) { this.hpzl = hpzl; } public List<?> getList() { return list; } public void setList(List<?> list) { this.list = list; } } list中的类: package com.glsx.biz.wzcx.common.model; /** * * 违章详细 * * @author hncdyj123@163.com */ public class IllegalRecordDetail extends BasePojo { /** * serialVersionUID */ private static final long serialVersionUID = -739130308826537426L; /** 日期 **/ private String date; /** 区域 **/ private String area; /** 违章行为 **/ private String act; /** 违章代码 **/ private String code; /** 扣分 **/ private String fen; /** 罚款 **/ private String money; private String frequency; private String isparking; public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getArea() { return area; } public void setArea(String area) { this.area = area; } public String getAct() { return act; } public void setAct(String act) { this.act = act; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getFen() { return fen; } public void setFen(String fen) { this.fen = fen; } public String getMoney() { return money; } public void setMoney(String money) { this.money = money; } public String getFrequency() { return frequency; } public void setFrequency(String frequency) { this.frequency = frequency; } public String getIsparking() { return isparking; } public void setIsparking(String isparking) { this.isparking = isparking; } } 然后返回时候 我用httpwatch 抓包 结果如下: 然后自己理解 还是把我list中的对象转成了一个单独的xml 所以xml格式不对 很少用到jdk里面实体映射xml的注解和相关方法,望LZ给予解答,谢谢! |
|
返回顶楼 | |
发表时间:2013-08-03
to hncdyj:
你的List<?> xxx 需要改成List<IllegalRecordDetail > 另外,IllegalRecordDetail 也要添加注解,参见附件中类似的例子。 |
|
返回顶楼 | |