-
Mar 27th, 2007, 06:15 AM
#1
Sitemesh + Spring MVC forward errors
Hi All
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:
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.Page Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
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:
<url-pattern>*.jsp</url-pattern>
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,
Martyn
-
Mar 27th, 2007, 10:36 AM
#2
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
#3
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,
Martyn
-
Mar 28th, 2007, 04:52 AM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules