当前位置: 首页>>代码示例>>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;未经允许,请勿转载。