美文网首页开发随笔
SpringBoot点餐随笔-买家端Dao

SpringBoot点餐随笔-买家端Dao

作者: 8813d76fee36 | 来源:发表于2017-10-13 10:45 被阅读7次

    命名习惯

    买家查看商品列表URL如下:

    GET /sell/buyer/product/list
    

    其中/sell是项目包名,SpringBoot配置项目包名(URL前缀)的配置项为server.context-path

    application.yml中配置URL前缀

    Controller最好也根据URL命名,如BuyerProductController对应RequestMapping为/sell/buyer/product/*

    使用@JsonProperty自定义返回的JSON的字段名

    实体类序列话成JSON时字段名默认和类中字段名保持一致,若需要自定义JSON中字段名,可以在实体类字段上@JsonProperty注解。下图中两个字段在JSON中将会命名为nametype

    自定义JSON字段名称

    相关文章

      网友评论

        本文标题:SpringBoot点餐随笔-买家端Dao

        本文链接:https://www.haomeiwen.com/subject/cdgnyxtx.html