You might have seen them already during your previous Java web development interviews but if you have not, it's a good question to know.
Similar to other Java web frameworks like Struts 1. A Front Controller is a common pattern in web applications and is used to receive requests and delegate to other components in the application for actual processing.
The DispatcherServlet is a front controller like it provides a single entry point for a client request to Spring MVC web application and forwards request to Spring MVC controllers for processing. How does DispatcherServlet know which request should be forwarded to which Controller? What is Dispatcher Servlet in Spring? Ask Question. Asked 11 years, 6 months ago. Active 9 months ago. Viewed k times. My Question is what does Dispatcher Servlet do? Kevin Kevin 22k 25 25 gold badges 75 75 silver badges bronze badges.
Add a comment. Active Oldest Votes. How it accomplishes this varies widely with configuration and Spring version. AdrieanKhisbe 3, 7 7 gold badges 32 32 silver badges 45 45 bronze badges. Affe Affe Great riposte, now a question how come the DispatcherServlet identifies the class name and method name too. Can you show me an example of a configuration where i have two classes and two method names and how DispatcherServlet catches the right request.
You can also wire it together with XML if you're oldschool. Is there any other type of servlet? I know this question is marked as solved already but I want to add a newer image explaining this pattern in detail source: spring in action 4 : Explanation When the request leaves the browser 1 , it carries information about what the user is asking for.
Eduardo Eduardo 1, 17 17 silver badges 22 22 bronze badges. I have a question please, how it select the view in case of returning JSON object that we see in the browser, does it return to the same URI if there is no logical view selected? Nesrin it's been ages since you asked but here's an answer : You put a special annotation just above the Controller method called ResponseBody indicating that the returned response should be directly written on HTTP response body, not to be placed in a Model or be resolved as view whatsoever.
Sanghyun Lee Is it something like events in Flex, where i get dispatch events from a one MXML to another or to server. Can i have more than one DispatcherServlet in my appication. Do each class files have a separate DispatcherServlet. There's usually only one front controller. This is regardless of the models and views you have. It just brings specific models and views together.
This is a nice explanation. However, I have seen projects which used name like "dispatcher" only, and it works fine. I too have tried that. But I do not know why?
Anurag S Anurag S 1 1 silver badge 7 7 bronze badges. Sign up or log in Sign up using Google. Newer Post Older Post Home. Subscribe to: Post Comments Atom. Subscribe for Discounts and Updates Follow.
Search This Blog. Interview Questions core java interview question data structure and algorithm 78 Coding Interview Question 75 interview questions 70 design patterns 35 SQL Interview Questions 34 object oriented programming 34 thread interview questions 30 spring interview questions 28 collections interview questions 25 database interview questions 16 servlet interview questions 15 Programming interview question 6 hibernate interview questions 6. How to design a vending machine in Java?
How HashMap works in Java? Why String is Immutable in Java?
0コメント