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