Spring 2 MVC and ResourceBundleViewResolver problem

This one took some time to figure out – it is one of those problems that are obvious after you know the solution but hard to see beforehand.

I had the ResourceBundleViewResolver configured with Tiles 2, like this:

<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="order" value="0"/>
<property name="basename" value="views"/>
<property name="defaultParentView" value="parent-view"/>
</bean>

and the view.properties was:

parent-view.(class)=org.springframework.web.servlet.view.JstlView
parent-view.(abstract)=true

about.url=/WEB-INF/jsp/about.jsp
form.url=/WEB-INF/jsp/form.jsp
list.url=/WEB-INF/jsp/list.jsp

It kept givin exception saying that /WEB-INF/jsp/list.jsp does not exist. Which it did. I tried couple of things, no result.

The problem was in trailing space AFTER list.jsp, therefore the path to JSP file searched for was “/WEB-INF/jsp/list.jsp “, not “/WEB-INF/jsp/list.jsp”.

Not sure if this is bug or feature – but removing trailing spaces should really be a sensible thing to do. As I found afterwards, the problem exists since 2005 – see this and this.

Advertisements

2 Responses to Spring 2 MVC and ResourceBundleViewResolver problem

  1. Eswar says:

    Nice information.

  2. Federica says:

    T-H-A-N-K Y-O-U!!!! I get this error and I didn’t know what to do, I’ve been saved by your post.

    Bug or feature? I would say criminal minds, but now I’m still angry…

%d bloggers like this: