title: How to make static images visible in Spring MVC application?
body: <p>I am unable to make static images visible in Spring MVC application.</p>
  
  <p>If I add</p>
  
  <pre><code>&lt;mvc:resources mapping="/images/**" location="/images/" /&gt;
  </code></pre>
  
  <p>into <code>dispatcher-servlet.xml</code> or <code>applicationContext.xml</code> then I am loosing an ability to execute controllers.</p>
  
  <p>My current <code>dispatcher-servlet.xml</code> is follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  
      &lt;context:component-scan base-package="com.inthemoon.snippets.springmvc" /&gt;
  
      &lt;mvc:resources mapping="/images/**" location="/images/" /&gt;
  
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>When I am opening <code>/hello</code> URL I am getting an error in log:</p>
  
  <pre><code>org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/hello] in DispatcherServlet with name 'dispatcher'
  </code></pre>
  
  <p>If I remove <code>resources</code> directive, I see the following messages in the log:</p>
  
  <pre><code>04-Dec-2015 22:30:15.687 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
  04-Dec-2015 22:30:16.012 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler Mapped URL path [/hello] onto handler 'helloWorldController'
  04-Dec-2015 22:30:16.013 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler Mapped URL path [/hello.*] onto handler 'helloWorldController'
  04-Dec-2015 22:30:16.013 INFO [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler Mapped URL path [/hello/] onto handler 'helloWorldController'
  </code></pre>
  
  <p>These messages are absent if <code>resources</code> directive is present.</p>