0
votes

I have a web server which forwards the dynamic requests with .htm to tomcat (connected using mod_jk) and static resources are served from Apache web server. Consider the following spring controller which process login.htm

@RequestMapping(method = {org.springframework.web.bind.annotation.RequestMethod.POST}, 
        value = {"login.htm"})
public ModelAndView showLoginPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
    return new ModelAndView("login");
}

Corresponding viewresolver is as follows:

<!bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/" />
    <property name="suffix" value=".html" />
</bean>

This is searching for a file login.html within the tomcat context. But the static login.html reside on htdocs folder of apache (under same domain).

Can anybody please tell me how can the view be resolved from web server?

1

1 Answers

0
votes

It is resolved. In our configuration apache does not allow .html request to tomcat. Earlier I had a misconception that spring would resolve the view via URL and the view would be accessible via web server. Rather spring resolve the view internally from the defined path in viewResolver.

So

<property name="prefix" value="/WEB-INF/html/" /> <property name="suffix" value=".html" />

and html pages in WEB-INF/html would be sufficient to resolve the view.

Spring would never route the view resolving request through web server.