title: Possible Bug in SpringMVC: Cannot handle servlet paths like / or /*
body: <p>I think I have discovered a bug in spring MVC, the JstlView does not work if the servlet path in the web xml is merely '/' or '/*' without the single quotes.  You can try it yourself, take any working web application based on spring MVC, and then adjust the dispatcher servlet path to just match '/' or '/*', and then go visit the page (with the new correct url of course) and you get a 400 error.</p>
  
  <p>Here is my example, I have a spring mvc app and this is in the web xml:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/mvc/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I deploy and visit:</p>
  
  <pre><code>http://localhost:8080/contextroot/mvc/template
  </code></pre>
  
  <p>and the page appears perfectly fine, here are the logs:</p>
  
  <pre><code>21:24:05.024 [http-bio-8080-exec-92] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /template
  21:24:05.048 [http-bio-8080-exec-92] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public java.lang.String com.project.www.controller.ResultController.getPersonList(org.springframework.ui.ModelMap)]
  21:24:05.050 [http-bio-8080-exec-92] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'resultController'
  21:24:05.056 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/contextroot/mvc/template] is: -1
  21:24:05.104 [http-bio-8080-exec-92] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'template'
  21:24:05.106 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'template'; URL [/WEB-INF/jsp/template.jsp]] in DispatcherServlet with name 'dispatcher'
  21:24:05.124 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/jsp/template.jsp] in InternalResourceView 'template'
  21:24:05.695 [http-bio-8080-exec-92] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
  </code></pre>
  
  <p>so it is all working above this line, but now I change web xml like so:</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I re-deploy and visit:</p>
  
  <pre><code>http://localhost:8080/contextroot/template
  </code></pre>
  
  <p>but I get a 400 error, here are the logs:</p>
  
  <pre><code>21:09:11.365 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/contextroot/template]
  21:09:11.372 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /template
  21:09:11.383 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Returning handler method [public java.lang.String com.AnnaUnivResults.www.controller.ResultController.getPersonList(org.springframework.ui.ModelMap)]
  21:09:11.384 [http-bio-8080-exec-78] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'resultController'
  21:09:11.387 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/contextroot/template] is: -1
  21:09:11.437 [http-bio-8080-exec-78] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'template'
  21:09:11.440 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'template'; URL [/WEB-INF/jsp/template.jsp]] in DispatcherServlet with name 'dispatcher'
  21:09:11.455 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/jsp/template.jsp] in InternalResourceView 'template'
  21:09:11.456 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/contextroot/WEB-INF/jsp/template.jsp]
  21:09:11.457 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /WEB-INF/jsp/template.jsp
  21:09:11.459 [http-bio-8080-exec-78] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/WEB-INF/jsp/template.jsp]
  21:09:11.460 [http-bio-8080-exec-78] WARN  o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/contextroot/WEB-INF/jsp/template.jsp] in DispatcherServlet with name 'dispatcher'
  21:09:11.461 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
  21:09:11.464 [http-bio-8080-exec-78] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
  </code></pre>
  
  <p>I am pretty sure this is a bug in spring.  I wanted to post this on spring's site, but apparently the spring questions page just sends you to StackOverflow, kind of deceptive if you ask me.</p>
  
  <p>I guess my question is, is this a bug?</p>