Mar 27th, 2007, 06:15 AM
Sitemesh + Spring MVC forward errors
I am having a problem using Sitemesh and Spring. Sitemesh on it's own works great but the problem occures when using Spring's MVC.
I have this in my web.xml:
When a form is validated, spring tries to forward from the validator to the to the controller. This invokes sitemesh and I get an error:
WARNING: No mapping for [/testapp/WEB-INF/jsp/secure/viewItem.do] in DispatcherServlet with name 'springapp'
So I added the following line to the filter mapping of sitemesh:
so that sitemesh is only invoked when forwarded to jsp files. I restart my web app and to my suprise, I still get the error mentioned above.
Anybody got an solution for this problem?
Thanks in advance,
Mar 27th, 2007, 10:36 AM
forwarding from validation to controller? When using the Spring validation this is all handled by the Controller. Just one method is called and that is handleRequest on the Controller.
Also the error you get isn't from sitemesh it is a message from the DispatcherServlet. Your form is probably being submitted to '/testapp/WEB-INF/jsp/secure/viewItem.do'. I figure it has to go to '/testapp/secure/viewItem.do'.
Mar 28th, 2007, 04:00 AM
mdeinum thanks for your response.
What I have discovered is the problem lies in the fact that the onSubmit method in my controller isnt called. I need:
public ModelAndView onSubmit( HttpServletRequest request, HttpServletResponse response, Object object, BindException bindException ) throws Exception
to be called because I need access to the object that contains the form information. I added logging information to my validator and controller. I see that the formBackingObject method is called, then the validator is called and then nothing. It seems as if the onSubmit method is skipped altogether.
The thing is I've used this system (Spring MVC) on another website of mine with the exact same setup. That website works prefectly. The only difference that I can imagine is that the spring version is different. Is it possible that in the latest spring version this isnt working? I am using version 2.0.3.
Thanks in advance,
Mar 28th, 2007, 04:52 AM
I found the problem. I was using java.net.BindException instead of org.springframework.validation.BindException. This prevented Spring from finding the method
public ModelAndView onSubmit( HttpServletRequest request, HttpServletResponse response, Object object, BindException bindException )
I want to thank you for your time. I hope if this happens to other people that they will find this forum post very fast and it will save them a day's work.