Friday, April 18, 2014

[Spring] Spring MVC Interview Questions

Explain Spring MVC framework with an example ? [Explain Spring MVC architecture]

http://thecafetechno.com/tutorials/spring/explain-spring-mvc-framework-with-example/



Question: What are the advantages of Spring MVC over Struts MVC ?
Answer:
1. There is clear separation between models, views and controllers in Spring.
2. Spring’s MVC is very versatile (有多種用途的﹐多功能的﹐萬用的) and flexible based on interfaces but Struts forces Actions and Form object into concrete inheritance.
3. Spring provides both interceptors and controllers.

Question: What is Controller in Spring MVC framework?
Answer:
In a general way, Controller (‘c’ in mvc ) delivers access to the behavior of application which is usually defined by a service interface and acts as glue between core application and the web.

It processes/interprets client data and transforms it to a domain object called model, which is finally represented to the client by the view.

Spring framework provides wide range of controllers.

In a specific way, Spring controllers are based on “org.springframework.web.servlet.mvc.Controller” Interface. 

Controller interface provides a single method that handles a request and returns a particular model and view as given in code snippet below.


public interface Controller {
     ModelAndView handleRequest( HttpServletRequest request,
                                HttpServletResponse response) throws Exception;
}
Question: What is a front controller in Spring MVC ?

Answer:
A front controller is defined as “a controller which handles all requests for a Web Application.”

DispatcherServlet (actually a servlet) is the front controller in Spring MVC that intercepts every request and then dispatches/forwards requests to an appropriate controller. The DispatcherServlet is declared in the web.xml file of web application. Requests which we want to be handled by DispatcherServlet should be mapped using URL mapping. For example all requests ending with *.htm will be handled by the DispatcherServlet.

Question: What is SimpleFormController in Spring MVC and how to use it in your web application ?

Question: What is AbstractController in Spring MVC ?

Question: What is ParameterizableViewController in Spring MVC ?    

Question: Why to override formBackingObject(HttpServletRequest request) method in Spring MVC?
 
Question: What is the use of overriding referenceData(HttpServletReques) in Spring MVC ?

Question: When and how to use MultiActionController in Spring MVC ?

Question: Which are the different method name resolvers in MultiActionController ? 

Link: http://thecafetechno.com/tutorials/spring/spring-mvc-interview-questions/   

http://www.tutorialspoint.com/spring/spring_interview_questions.htm 

No comments:

Post a Comment