Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!