本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}