title: Why can't Spring find resource files?
body: <p>I'm running NetBeans with Spring framework. The web page shows up but it is not formated. It doesn't find the css and js files.  What am I doing wrong?</p>
  
  <p><strong>NetBeans</strong></p>
  
  <p><a href="https://i.stack.imgur.com/cMcPI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cMcPI.jpg" alt="enter image description here"></a></p>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;MedAI - Medical Artifical Intelligence&lt;/title&gt;
      &lt;script type="text/javascript" src="resources/js/jquery.js"&gt;&lt;/script&gt;     
      &lt;script type="text/javascript" src="resources/js/jquery-ui.js"&gt;&lt;/script&gt;  
      &lt;script type="text/javascript" src="resources/js/jquery.dataTables.js"&gt;&lt;/script&gt;        
      &lt;link href="resources/css/jquery-ui.css" rel="stylesheet" type="text/css" /&gt;
      &lt;link href="resources/css/medai.css" rel="stylesheet"  type="text/css" /&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
      &lt;div&gt;
              &lt;h1&gt;MedAI&lt;/h1&gt;
              &lt;span class=version&gt;V 1.0.0&lt;/span&gt;            
      &lt;/div&gt;
  
      &lt;div id="tabs"&gt;
      &lt;ul&gt;
              &lt;li&gt;&lt;a href="&lt;c:url value='/jsp/homeTab' /&gt;"&gt;Home&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="&lt;c:url value='/jsp/geneNetworkTab' /&gt;"&gt;Gene Network&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="&lt;c:url value='/jsp/diseaseNetworkTab' /&gt;"&gt;Disease Network&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;  
      &lt;/div&gt;
          &lt;script type="text/javascript"&gt;
              $(document).ready(function() {
              $('#tabs')
                  .tabs()
                  //.addClass('ui-tabs-vertical ui-helper-clearfix');
              });    
          &lt;/script&gt;    
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>dispatcher-servlet.xml</strong></p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!-- was: &lt;?xml version="1.0" encoding="UTF-8"?&gt; --&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:p="http://www.springframework.org/schema/p"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"&gt;
  
      &lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt;
  
      &lt;!--
      Most controllers will use the ControllerClassNameHandlerMapping above, but
      for the index controller we are using ParameterizableViewController, so we must
      define an explicit mapping for it.
      --&gt;
      &lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
          &lt;property name="mappings"&gt;
              &lt;props&gt;
                  &lt;prop key="index.htm"&gt;indexController&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="viewResolver"
            class="org.springframework.web.servlet.view.InternalResourceViewResolver"
            p:prefix="/WEB-INF/jsp/"
            p:suffix=".jsp" /&gt;
  
      &lt;!--
      The index controller.
      --&gt;
      &lt;bean name="indexController"
            class="org.springframework.web.servlet.mvc.ParameterizableViewController"
            p:viewName="index" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>redirect.jsp</strong></p>
  
  <pre><code>&lt;%--
  Views should be stored under the WEB-INF folder so that
  they are not accessible except through controller process.
  
  This JSP is here to provide a redirect to the dispatcher
  servlet but should be the only JSP outside of WEB-INF.
  --%&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;% response.sendRedirect("index.htm"); %&gt;
  </code></pre>