I try to configure simple Controller.
I have:
in web.xml
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
in mvc-dispatcher-servlet.xml
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/index.jsp">
<ref bean="mainPage"/>
</entry>
</map>
</property>
</bean>
<bean name="mainPage" class="ru.mypack.TBController" />
here is my Controller:
public class TBController extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
System.out.println("It is here");
ModelAndView model = new ModelAndView("index");
return model;
}}
I run in on Tomcat 6 and in this configuration it (/index.jsp) works perfect!
But if I change url-pattern like this
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
it returns 404 accessing /index.jsp
I see "It is here" in console, it means url-pattern works fine but ModelAndView doesn't get initialized
Strange thing is that it looks like he tries to access empty resource
(Chrome dysplays me "HTTP Status 404 - ")
Please, help me to understand what is going on.. May be I missed something in url-pattern specification?
UPD:
Thanks to Pavel Horal, the solution has been found.
I just replaced my url-pattern in web.xml with
<url-pattern>/test/*</url-pattern>
And now it responds by /test/index.jsp