Brad Lucas

A blog mostly about programming
January 10, 2007

Bad Markup Causing Multiple Calls To Spring Controller

Had an interesting problem come up with a client using Spring MVC. For some reason they where experiencing GET requests to a Controller resulting in two calls to the Controller. It was as if the browser was making to requests for each user initiated request. Of course, implementing a simple version of the controller and a basic view did not reproduce the problem. Going back to the application and logging continued to verify that the handleRequestInternal was in fact being entered twice.

Nest, the Controller and it’s View where slimmed down a bit to localize the problem. A single test url was setup to point to this controller. Then iteratively parts where changed. Any unnecessary processing was removed so the Controller was excercised from a link and simply returned the View. This still showed the problem. Next, the view was replaced with a very minimal Jsp. When this happened the problem went away. Could something in the existing View cause the Controller to be called again? This didn’t seem likely but it certainly seemed to be true.

Returning to the original view, and selectivly removing one section at at time until the problem went away eventually localized the offending part of the View.

Inside the HTML tag for a TABLE where was a background=”#C3D9FF”. This invalid attribute looked to cause the browser to recall the page as it expected the background to be associated with the BODY.

Replacing the background with bgcolor tag fixed the problem.


Tags: java