當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerMapping.getHandler方法代碼示例

本文整理匯總了Java中org.springframework.web.servlet.HandlerMapping.getHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java HandlerMapping.getHandler方法的具體用法?Java HandlerMapping.getHandler怎麽用?Java HandlerMapping.getHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.servlet.HandlerMapping的用法示例。


在下文中一共展示了HandlerMapping.getHandler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHandler

import org.springframework.web.servlet.HandlerMapping; //導入方法依賴的package包/類
@Override
public HandlerExecutionChain getHandler(HttpServletRequest request)
		throws Exception {
	if (this.mappings == null) {
		this.mappings = extractMappings();
	}
	for (HandlerMapping mapping : this.mappings) {
		HandlerExecutionChain handler = mapping.getHandler(request);
		if (handler != null) {
			return handler;
		}
	}
	return null;
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:15,代碼來源:EndpointWebMvcChildContextConfiguration.java

示例2: requestsWithoutHandlers

import org.springframework.web.servlet.HandlerMapping; //導入方法依賴的package包/類
@Test
public void requestsWithoutHandlers() 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);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:14,代碼來源:BeanNameUrlHandlerMappingTests.java

示例3: asteriskMatches

import org.springframework.web.servlet.HandlerMapping; //導入方法依賴的package包/類
@Test
public void asteriskMatches() 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);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:BeanNameUrlHandlerMappingTests.java

示例4: getHandler

import org.springframework.web.servlet.HandlerMapping; //導入方法依賴的package包/類
private HandlerExecutionChain getHandler(HandlerMapping hm, MockHttpServletRequest req) throws Exception {
	HandlerExecutionChain hec = hm.getHandler(req);
	HandlerInterceptor[] interceptors = hec.getInterceptors();
	if (interceptors != null) {
		for (HandlerInterceptor interceptor : interceptors) {
			interceptor.preHandle(req, null, hec.getHandler());
		}
	}
	return hec;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:11,代碼來源:SimpleUrlHandlerMappingTests.java

示例5: doTestRequestsWithSubPaths

import org.springframework.web.servlet.HandlerMapping; //導入方法依賴的package包/類
private void doTestRequestsWithSubPaths(HandlerMapping hm) throws Exception {
	Object bean = wac.getBean("godCtrl");

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

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

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

	req = new MockHttpServletRequest("GET", "/myapp/myservlet/mypath/welcome.html");
	req.setContextPath("/myapp");
	req.setServletPath("/myservlet");
	hec = hm.getHandler(req);
	assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);

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

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

	req = new MockHttpServletRequest("GET", "/mypath/bookseats.html");
	hec = hm.getHandler(req);
	assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:39,代碼來源:BeanNameUrlHandlerMappingTests.java


注:本文中的org.springframework.web.servlet.HandlerMapping.getHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。