Skip to main content

Spring MVC, Tiles and Jetty

Posted by johnsmart on July 10, 2007 at 2:53 PM PDT

This entry is a short note on an issue I found when using Spring MVC, Tiles and Jetty together. I couldn't find any mention of it on Google, so maybe it only happens on my machine (yeah right...). I've been working on a project using Spring MVC and Tiles. I've also been using the (relatively recent)

tags, which are cool. And I've been using Jetty to speed up the development cycle. At least, that's the theory...

Anyway, when using Jetty, it seems that the tag renders the "action" attribute as "/WEB-INF/jsp/layout.jsp". This obviously doesn't work. Anyone familiar with Spring MVC will know that the tag should generate an action tag that points back to the current page. Now after digging into the Spring-MVC code, I'm pretty sure it's not Spring's fault. Spring just gets the request URI from the container. And in Tomcat, everything works fine. So if stones are to be thrown, they would probably fall in the jetty.

I wasn't too keen on dropping the nice tags, especially since they worked fine in the target environment (Tomcat). The work-around is actually quite simple, once you know the source of the problem. To get it working in both Tomcat and Jetty, you need to force the action parameter to "?", as shown here:

<form:form commandname="chooseProfile" action="?">

This will force the form to submit to its page of origin, which is exactly what we want.

Jetty is nice as it is fast to start and supports hot-deploy of JSPs, which makes it a good test platform. However, it has a slightly non-standard behaviour in some areas, like this one.

Related Topics >>