Overriding The Spring DispatcherServlet For Developer Feedback
The Spring DispatcherServlet can be easily overriden to output all of the key communication coming from the browser to the server.
- Home
- Overriding The Spring DispatcherServlet For Developer Feedback
The Importance Of Having Good Developer Feedback
Having good developer feedback in your web application is critical to efficient development
and debugging. Overriding the Spring DispatcherServlet allows you to show the following to the
developer in the web application console, or in logs. Of course, the feedback isn't limited to these items
only but these are the most important. Ideally you will want to program this to only
be enabled in a development environment and turned off in production.
-
The URL/URI being called. This helps the developer determine which controller method is being called.
-
The time the call is being made, just to help the developer sort out which calls are part of the same request.
-
The parameters being sent from the browser, both name and value.
-
The view being returned.
Specifying The Overriden DispatcherServlet in web.xml
Spring's main entry point in a web application is the DispatcherServlet. Therefore, to use your own version you simply
replace Spring's implementation with your implementation
that extends the Spring version. The reference is located in web.xml in your web application in the "/web-inf" folder.
An example of this configuration is shown below.
The Spring documentation is located here
Spring MVC Documentation
Example web.xml entry
Overriding The DispatcherServlet
Make sure that the Spring MVC jar files are in your java build path. Below is
a working example code for the Dispatcher override. More information can be found
at
An Intro to the Spring DispatcherServlet.
Notice that ultimately the super class version of the same method is also called.