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


Java HandlerMethod.getBean方法代碼示例

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


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

示例1: preHandle

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Object handlerBean = handlerMethod.getBean();
        if (handlerBean instanceof ControllerBase) {
            List<Authorize> authorizes = new ArrayList<>();
            Authorize authorize = handlerMethod.getMethodAnnotation(Authorize.class);
            if (authorize != null) {
                authorizes.add(authorize);
            }
            authorize = handlerMethod.getBeanType().getAnnotation(Authorize.class);
            if (authorize != null) {
                authorizes.add(authorize);
            }
            if (authorizes.size() > 0) {
                userContextProcessor.process(
                        authorizes.stream().map(Authorize::permission).reduce((p1, p2) -> p1 + p2).get(),
                        request, response);
            }
        }
    }
    return true;
}
 
開發者ID:richterplus,項目名稱:spring-cloud-sample,代碼行數:25,代碼來源:AuthorizationInterceptor.java

示例2: preHandle

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
	boolean filter = false; 
    User user = (User) request.getSession(true).getAttribute(UKDataContext.USER_SESSION_NAME) ;
    HandlerMethod  handlerMethod = (HandlerMethod ) handler ;
    Menu menu = handlerMethod.getMethod().getAnnotation(Menu.class) ;
    if(user != null || (menu!=null && menu.access()) || handlerMethod.getBean() instanceof BasicErrorController){
    	filter = true;
    }
    
    if(!filter){
    	response.sendRedirect("/login.html?referer="+java.net.URLEncoder.encode(request.getRequestURL().toString() , "UTF-8"));
    }
    return filter ; 
}
 
開發者ID:uckefu,項目名稱:uckefu,代碼行數:16,代碼來源:UserInterceptorHandler.java

示例3: assertUniqueMethodMapping

import org.springframework.web.method.HandlerMethod; //導入方法依賴的package包/類
private void assertUniqueMethodMapping(HandlerMethod newHandlerMethod, WxMappingInfo mapping) {
    HandlerMethod handlerMethod = this.mappingLookup.get(mapping);
    if (handlerMethod != null && !handlerMethod.equals(newHandlerMethod)) {
        throw new IllegalStateException(
                "Ambiguous mapping. Cannot map '" + newHandlerMethod.getBean() + "' method \n" +
                        newHandlerMethod + "\nto " + mapping + ": There is already '" +
                        handlerMethod.getBean() + "' bean method\n" + handlerMethod + " mapped.");
    }
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:10,代碼來源:WxMappingHandlerMapping.java


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