Understanding Spring MVC sub-project -


i have experience in using spring mvc framework, however, still have doubts. understand, mvc framework helps in writing web applications using mvc design pattern.

now, tried understand better, came know uses 2 design patterns: "front controller" followed "mvc" design pattern`.

the first part understood, "front controller" provided spring mvc in form of dispatcherservlet intercepts incoming requests intended it.

where "mvc framework" in spring mvc framework? understood, developer writes controller, model, view. if developer doesn't write code of, controller there nothing framework provides controller.

i having difficulty how spring mvc supports mvc pattern when developer has write code.

let me explain taking controllers example.

yes.at first glance, may seems spring doing nothing.

it might because of integration code between application code , framework reduced annotations.so developers missed notice single word "@controller" , started searching "where mvc"?

spring 2.5 controller sample:

because of "implements controller", spring's role more noticeable here.

import org.springframework.web.servlet.mvc.controller;  public class hellocontroller implements controller {  } 

spring 4 controller:

now spring's contribution less noticeable/visible. more or less class might looks our own plain java class without framework.

@controller @requestmapping("/") public class helloworldcontroller { 

mvc architectural pattern defines architecture of application components , interaction (request/data flow) between components.

always developers has write business/application logic themselves.

developers extending spring mvc's controllers. developers extending spring mvc's models. developers request mapping between request urls , controller methods. but, how mapping happens while request comes ? - duty of spring mvc, application developers no need bother.

in plain old servlet days too, application developers did mapping mentioning http method , doget(), dopost() etc.

similarly, models annotated @repository. , view either old days jsp or modern day angular js...

so, in short, mvc there , less visible now-a-days.

i hope answer gives insights.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -