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?
phpcn_u15822017-05-16 17:06:31
0
13
1102
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?
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
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
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.
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
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
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.