search

Home  >  Q&A  >  body text

java - How to transfer values ​​​​between the controller layer and the service layer?

The current architecture controller layer and service layer use map<string, string> to transfer values. It feels that value conversion is very troublesome in many cases; but if bean objects are used to transfer values, many beans specifically used to transfer values ​​need to be built. . . . Please give me some advice from the architecture master

阿神阿神2775 days ago1184

reply all(4)I'll reply

  • 某草草

    某草草2017-05-17 09:59:48

    This is a detailed code implementation issue, not the architecture. .

    There is obviously a problem with using map to pass parameters. Using encapsulated model to pass values ​​is more semantically clear and easy to maintain. Having too many models is not a problem

    If you feel that converting from map to model every time is cumbersome, you can use the BeanUtil tool or write a tool class yourself to do the conversion

    reply
    0
  • 黄舟

    黄舟2017-05-17 09:59:48

    I agree with the above, many models can be layered using packages

    Try to write code that is easy to maintain. Using map as return parameter will be a nightmare for future maintenance

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-17 09:59:48

    I agree with the first floor. It is recommended that if there are few parameters, directly pass the variable of the specified type. If there are many parameters, directly create a dto and pass the parameters to the object

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-17 09:59:48

    It is recommended to use beans to pass values, which is safe, reliable and easy to maintain. If the business requires many beans, the beans must be subcontracted and managed hierarchically. A clear and hierarchical project file structure will help clarify development ideas.

    reply
    0
  • Cancelreply