Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
searching controller in a web application

I am new to Spring-mvc. In my first tutorial I am having a doubt, we create a servelet of DispatcherServlet in web.xml and mark our controller using @contorller annotation. Then using @Requestmapping annotation we filter url for function to be invoked.

How Spring searches for controller in the webapp? Which function actually invoked in DispatcherServelet to create a instance of controller class? Can i have multiple controller in my application?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

How Spring searches for controller in the webapp?

Spring container scans through all of the packages specified through @ComponentScan annotation (or using component-scan in xml config) and when you mark your bean class with stereotype annotation like @Controller, Spring container will create the instance (by default singleton scope) of your controller class and maps the url along with the request method type(like GET, POST, PUT, etc..). The other stereotype annotation are listed here (like @Service, etc..) and the container creates objects for these types as well.

Which function actually invoked in DispatcherServelet to create a instance of controller class?

Spring core container creates the instances for all beans annotated with stereotypes (as explained above during container start up) and then Dispatcherservlet uses HandlerMapping to map the urls to the controller methods and RequestMappingHandlerMapping implementation is being used by default and when the request comes, it will be delegated to the respective the controller method, you can look here.

Can I have multiple controllers in my application?

Yes, you can define multiple controllers in your application. In a typical web application project, you would see many controller classes each mapped with the respective urls and the business logic being handled through their service classes.

I suggest you refer this to understand on how the spring web flow works.

about 4 years ago · Santiago Trujillo Denunciar

0

Can I have multiple controller in my application?

Yes.You can create multiple controller in your application.You can get more idea following this post.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda