RESTful Service use comment

Java RESTful

  • 注解

    • @ApplicationPath
    • @Path // 声明资源路径 @Path("/book") or @Path("/{bookId: [0-9]*}")
      • @PathParam("bookId") <- [PUT POST DELETE]
      • @QueryParam("ip") // query param <- [GET]
    • @Consumes 标识输入实体的类型
      • @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
    • @Produces 标识返回实体的类型
      • @Produces(MediaType.TEXT_PLAIN) // 传输格式是字符串类型 text/plain
      • @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    • MediaType

            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-moxy</artifactId>
            </dependency>
      
    • @PUT // http protocol put method
    • @POST // http protocol post method
    • @DELETE // http protocol delete method
    • @GET // http protocol get method
    • Jersey 内部 JAXB 处理 java pojo class 和 xml 格式的信息、json 格式的信息映射:
      • XML
        • @XmlRootElement(name= "book") // root node
        • @XmlElement(name= "book")
        • @XmlAttribute(name= "status") // node attribute
        • @XmlElementWrapper
      • JSON

持续更新...

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容