本文整理匯總了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);
}