title: How to serve static resources from a Vaadin/Spring application?
body: <p>I have  Vaadin web application with spring security integration for authentication. The configuration of the Vaadin servlet is pretty simple:</p>
  
  <pre><code>&lt;servlet&gt;
  
      &lt;servlet-name&gt;Vaadin Application Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.example.SpringApplicationServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;applicationBean&lt;/param-name&gt;
          &lt;param-value&gt;mainApplication&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;widgetset&lt;/param-name&gt;
          &lt;param-value&gt;com.example.widgetset.CustomWidgetSet&lt;/param-value&gt;
      &lt;/init-param&gt;
  
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Vaadin Application Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The servlet initializes the Spring Context and returns the Vaadin application. I have also configured the security for that and have a custom login form configured like this:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;login&lt;/servlet-name&gt;
      &lt;jsp-file&gt;/jsp/login.jsp&lt;/jsp-file&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;login&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/login&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;login_error&lt;/servlet-name&gt;
      &lt;jsp-file&gt;/jsp/loginError.jsp&lt;/jsp-file&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;login_error&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/login_error&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The login form is styled with an external css and there are also some images. Basically the images are located in /jsp/img and the stylesheet in /jsp/login.css. So the WAR structure looks like:</p>
  
  <ul>
  <li>/jsp</li>
  <li>/META-INF</li>
  <li>/VAADIN</li>
  <li>/WEB-INF</li>
  </ul>
  
  <p>Neither the images nor the css gets loaded, because obviously all those requests are mapped to the vaadin servlet. How can I define some static resources directory, which wouldn't be served by the Vaadin servlet? I have tried the spring mvc:resources but that didn't work. Thank you for your help.</p>
  
  <p>Bye,
  Filip</p>
  
  <p>I have figured this out. Although it is rather a workaround. I have mapped the Vaadin Application Servlet to something like /app/* instead of to /* (Remember that in this case you also have to map the same servlet to /VAADIN/*). With this configuration I am able to access the jsp directory from my webapp and everything works fine. I have deleted the whole Spring Resources configuration, as this just didn't work.</p>
  
  <p>So once more, I am still pretty not pretty comfortable with this solution and would rather have my RESOURCES dir configured other way, but the client is happy :). If anyone has got the right solution I would appreciate to read it.</p>