This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Tiles Integration in Spring 3

Jun 2nd, 2012, 03:46 AM

Hello to all,

I have create a web site using Tiles for templating purposes but when i redirect the index.jsp to home.jsp. It throw exception unable to resolve the view name. There is home.jsp available in WebContent folder.

Why is it cannot resolve the view name ?
Is there any method to resolve the view name to default if nothing found?

Comment

Your application is not configured correctly. You should have one application context that contains beans that are "universal" to your application, while you can have many dispatcher servlets configured. Think about it this way -- your context should know about the application, but not about the implementation details (the servlets), while your servlets should have knowledge of the application, but not each other. It should look something like this:

Now create two configuration files, one called applicationContext.xml, and the other called spring-servlet.xml, and place them both under the /WEB-INF/ directory. Actually, if you don't want to rename applicationContext.xml to something different, then you can do away with the contextConfigLocation context parameter altogether. Also, don't bother with the index.jsp redirection, and remove the welcome file list. You can create a controller that catches the "root" or "home" with the above configuration and the following handler:

Comment

By using InternalResourceViewResolver, i will specify "/home" but when using URIBasedView Resolver, need to specify "home"(View name) and not the URI itself.

For all the view in jsp, need to specify in Tiles configuration file, it is quite bad.
Why it is view name rather that it is URL?

Is this correct?

I found one thing very strange where view cannot be render (display header.jsp, menu.jsp blah blah) when jsp file locate at WebContent folder but when i move to WEB-INF folder, the view can be render. What is the reason?