亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Interface Document - How does the java background interface conveniently return restful data?
PHP中文網
PHP中文網 2017-05-27 17:39:59
0
2
845

When using spring mvc,
the json data you pass to the front end (ios/android) is converted by spring to the beans, right?
Are these beans all defined java classes?

Because I feel that the json required by the front end is very flexible. If the backend is encapsulated with several large and complete beans, the front end will get many useless fields.
(Although you can control the serialization strategy so that fields with null values ??or even default values ??do not appear in json, but in this way, the fields will be incomplete and the readability will be poor.)
If you refine the bean, you need Too many beans are created.

In our project, we basically use map to construct the required data (mainly because we use jdbctemplate, and the queried data is map type). There is no need to define bean classes. Although it is very flexible, it is often troublesome to write the key name by hand. location.

How did everyone solve it? Please feel free to give me your advice, thank you!

PHP中文網
PHP中文網

認證高級PHP講師

reply all(2)
PHPzhong

Use Spring WebMVC’s Controller directly and add @ResponseBody to return POJO

Peter_Zhu

In the past, Map was used to combine data, but handwriting Key names is really troublesome and easy to make mistakes. This is the so-called magic value and should be avoided as much as possible. Later, they switched to small and beautiful beans. Each interface corresponds to a bean. Although the number is relatively large, the coupling is looser than establishing a large and comprehensive bean. Modifying the bean will not affect other interfaces, which is still acceptable. I don’t know if there is one. There is no other more elegant solution.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template