Package org.springframework.web.servlet

Examples of org.springframework.web.servlet.HandlerMapping


    wac.setConfigLocations(new String[] {CONF});
    wac.refresh();
  }

  public void testRequestsWithoutHandlers() throws Exception {
    HandlerMapping hm = (HandlerMapping) wac.getBean("handlerMapping");

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/mypath/nonsense.html");
    req.setContextPath("/myapp");
    Object h = hm.getHandler(req);
    assertTrue("Handler is null", h == null);

    req = new MockHttpServletRequest("GET", "/foo/bar/baz.html");
    h = hm.getHandler(req);
    assertTrue("Handler is null", h == null);
  }
View Full Code Here


    h = hm.getHandler(req);
    assertTrue("Handler is null", h == null);
  }

  public void testRequestsWithSubPaths() throws Exception {
    HandlerMapping hm = (HandlerMapping) wac.getBean("handlerMapping");
    doTestRequestsWithSubPaths(hm);
  }
View Full Code Here

    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
  }

  public void testAsteriskMatches() throws Exception {
    HandlerMapping hm = (HandlerMapping) wac.getBean("handlerMapping");
    Object bean = wac.getBean("godCtrl");

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/mypath/test.html");
    HandlerExecutionChain hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/testarossa");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

    req = new MockHttpServletRequest("GET", "/mypath/tes");
    hec = hm.getHandler(req);
    assertTrue("Handler is correct bean", hec == null);
  }
View Full Code Here

    wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2.xml"});
    wac.refresh();
    Object bean = wac.getBean("mainController");
    Object otherBean = wac.getBean("otherController");
    Object defaultBean = wac.getBean("starController");
    HandlerMapping hm = (HandlerMapping) wac.getBean(beanName);

    MockHttpServletRequest req = new MockHttpServletRequest("GET", "/welcome.html");
    HandlerExecutionChain hec = getHandler(hm, req);
    assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
    assertEquals("/welcome.html", req.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  protected Map<String, List<Resource>> getMappingLocations()
      throws IllegalAccessException {
    HandlerMapping mapping = (HandlerMapping) this.context
        .getBean("resourceHandlerMapping");
    Map<String, List<Resource>> mappingLocations = new LinkedHashMap<String, List<Resource>>();
    if (mapping instanceof SimpleUrlHandlerMapping) {
      Field locationsField = ReflectionUtils.findField(
          ResourceHttpRequestHandler.class, "locations");
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.HandlerMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.