title: Servlet mapping - unable to access my resources (css & js)
body: <p>I'm very confused with servlet mapping. From what i understand </p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>is that all xx.htm will go into this servlet.</p>
  
  <p>I have no problem accessing these 2 web page (able to retrieve css &amp; js)</p>
  
  <pre><code>http://localhost:8080/smartcoursesystem/university.htm
  http://localhost:8080/smartcoursesystem/home.htm
  </code></pre>
  
  <p>The problem is when i go to this path </p>
  
  <pre><code>http://localhost:8080/smartcoursesystem/university/edit.htm
  </code></pre>
  
  <p>At this page, all my resource(css &amp; js) are missing. What is the problem?</p>
  
  <p>My dispatcher servlet</p>
  
  <pre><code>&lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt;
  
  &lt;context:component-scan base-package="controller"/&gt;
  &lt;mvc:annotation-driven/&gt;
  &lt;mvc:default-servlet-handler /&gt;
  &lt;mvc:resources location="/assets/" mapping="/assets/**"/&gt;
  
  &lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"/&gt;
  
  &lt;bean id="viewResolver" 
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        p:prefix="/WEB-INF/jsp/"
        p:suffix=".jsp" /&gt;
  </code></pre>
  
  <p>Web.xml</p>
  
  <pre><code>&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;/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;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>@Controller
  @RequestMapping(value="/university")
  public class universityController {
  
  public static String entity_name = "University";
  
  @RequestMapping()
  public String getAll(Model m){
  
      universityModel model = new universityModel();
      univCrsModel uc = new univCrsModel();
      m.addAttribute("univList", model.getAll());
      m.addAttribute("entity", entity_name);
      m.addAttribute("countUniv", model.countUniv());        
  
      return "all";
  }
  
  @RequestMapping(value="/edit", method=RequestMethod.GET)
  public String edit(@RequestParam(value="id") int id, Model m){
  
      universityModel model = new universityModel();        
      m.addAttribute("univ", model.getUniv(id));
      m.addAttribute("entity", entity_name);
  
      return "edit";
  }
  </code></pre>
  
  <p>edit.jsp</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Edit University Profile&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;img src="/assets/images/icon-128x128.png" alt="smart course"&gt;
          //more code
      &lt;/body&gt;
  &lt;/htm&gt;
  </code></pre>
  
  <p>I have tried change my url-pattern to "/ " but doesn't help. In fact, changing url-pattern to "/" make my welcome file not working.</p>