Saturday, 16 November 2013

spring web mvc interview questions

Question: Explain Spring MVC framework with an example ?
Ans: Explain Spring MVC architecture with an example ? The MVC is a standard software architecture that aims to separate business logic from presentation logic, enabling the development, testing and maintenance of both isolated . (1) The user triggers an event through the UI (click a button on the page or something).
(2) The controller receives the event and coordinates how things will happen on the server side, i.e. the flow goes to the objects required to perform the business rule.
To see Spring MVC hello world example
Question: What are the advantages of Spring MVC over Struts MVC ?
Ans: 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..
To see Spring MVC hello world example 
Question: What is Controller in Spring MVC framework?
Ans: 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.. 
Question: What is a front controller in Spring MVC ?
Ans: 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.. 
Question: What is SimpleFormController in Spring MVC and how to use it in your web application ?
Ans:It offers you form submission support. This can help in modeling forms and populating them with model/command object returned by the controller. After filling the form, it binds the fields, validates the model/command object, and passes the object back to the controller so that the controller can take appropriate action.. 
Question: What is AbstractController in Spring MVC ?
Ans:AbstractController : It provides a basic infrastructure and all of Spring’s Controller inherit from AbstractController. It offers caching support, setting of the mimetype etc. It has an abstract method ‘handleRequestInternal(HttpServletRequest, HttpServletResponse)’ which should be overridden by subclass.. 
Question: What is ParameterizableViewController in Spring MVC ?
Ans:ParameterizableViewController : ParameterizableViewController is one of the concrete Spring’s Controller. This controller returns a view name specified in Spring configuration xml file thus eliminates the need of hard coding view name in the controller class as in case of AbstractController..
Question: Why to override formBackingObject(HttpServletRequest request) method in Spring MVC?
Ans:You should override formBackingObject(HttpServletRequest request) if you want to provide view with model object data so that view can be initialized with some default values e.g. Consider in your form view..
Question: What is the use of overriding referenceData(HttpServletReques) in Spring MVC ?
Ans: Overridden referenceData() method is used to provide some additional information to the formView (fillForm.jsp) to construct and display the view e.g.
In your form view you want to give various options to user say in the form of checkboxes and user can select multiple options. For this You can create multiple checkboxes in your view and corresponding multiple instance variables in your command/model object.
Question: When and how to use MultiActionController in Spring MVC ?
Ans: MultiActionController supports the aggregation of multiple request-handling methods into one controller, so allows you to group related functionality together. It is capable of mapping requests to method names and then invoking the correct method to handle a particular request… 
Question: Which are the different method name resolvers in MultiActionController ?
Ans: MultiActionController needs some way to resolve which method to call when handling an incoming http request. Spring provides MethodNameResolver interface to achieve this. The MultiActionController class provides a property named ‘methodNameResolver’ so that you can inject a MethodNameResolver… 

No comments:

Post a Comment