search

Home  >  Q&A  >  body text

In the MVC development framework, when checking the validity of the content entered by the user when submitting, is it completed by c or m?

Currently when you use the mvc development framework, when checking the legality of user input text on the user front end, when the user submits, should this be handled by the c layer or the m layer?

phpcn_u1582phpcn_u15822833 days ago1149

reply all(13)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 17:08:31

    Model layer. First of all, the Controller does not do any verification. The View layer can also do verification, but it is usually placed on the model layer

    reply
    0
  • 某草草

    某草草2017-05-16 17:08:31

    M layer and C layer are not verified. Generally, there will be a Service on the M layer, and processing is usually done in the Service.
    Why not do the verification in the Controller? Because we need to take into account the webservice. The same business has two Controllers for the page and the webservice, so the code written in the Controller cannot be reused

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 17:08:31

    M layer
    You have to remember: MVC
    The M layer handles everything related to data.
    The V layer handles everything related to data presentation.
    The C layer just wants a data pipeline to link these contents.

    reply
    0
  • Cancelreply