Java Restful Response返回缺少列表名称

时间:2016-06-10 14:27:13

标签: java json rest jax-rs

我一直试图找到问题的答案,但到目前为止,我一直没有成功。我正在尝试进行POST操作:

@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@POST
@Path(value="/search")

{
  "firstName": "JOHN",
  "lastName": "SMITH"
}

结果:

{
  "members": [
    {
      "memberID": "1",
      "firstName": "JOHN",
      "lastName": "SMITH",
      "memberAddresses": {
        "memberAddresses": [
          {
            "memberAddressID": 74128225,
            "addr1": "123 MAIN ST",
          }
         ]
       }

WEB.XML:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>CIS-Services</display-name>
    <servlet>
        <description>
        JAX-RS Tools Generated - Do not modify</description>
        <servlet-name>JAX-RS Servlet</servlet-name>
        <servlet-class>com.ibm.websphere.jaxrs</servlet-class>
        <load-on-startup>1</load-on-startup>
        <enabled>true</enabled>
        <async-supported>false</async-supported>
    </servlet>
    <resource-ref>
    <description />
    <res-ref-name>jdbc/CISDB_DS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <servlet-mapping>
        <servlet-name>JAX-RS Servlet</servlet-name>
        <url-pattern>
        /*</url-pattern>
    </servlet-mapping>
</web-app>

结果是正确的,但是我在内部列表中得到了重复的标签(memberAddresses)。有没有办法只返回第二个memberAddresses标签?

0 个答案:

没有答案