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


Java MethodParameter.hasParameterAnnotation方法代碼示例

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


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

示例1: getAccessUser

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
protected AdminUser getAccessUser(HttpServletRequest request, LoggingContext loggingContext) {
	if(loggingContext.getHttpAccessLogging().isLogin()){ //用戶正在登錄
		HandlerMethod handlerMethod = loggingContext.getHandlerMethod();
		MethodParameter[] methodParameters = handlerMethod.getMethodParameters();
		if(methodParameters != null){
			for(MethodParameter methodParameter : methodParameters){
				if(methodParameter.hasParameterAnnotation(RequestBody.class) && AdminUser.class.equals(methodParameter.getParameterType())){
					HttpRequestParameter requestParameter = loggingContext.getHttpAccessLog().getRequestParameter();
					Object requestBody = requestParameter.getBody();
					MediaType contentType = loggingContext.getHttpAccessLog().getRequestContentType();
					if (contentType != null && requestBody != null && requestBody instanceof Map && MediaType.APPLICATION_JSON.getType().equals(contentType.getType())) {
						Map<String,Object> requestBodyMap = (Map<String, Object>) requestBody;
						return adminUserService.getUserByUserName(MapUtils.getString(requestBodyMap, "userName"), false);
					}
				}
			}
		}
		return null;
	}else{ //用戶已登錄
		LoginToken<AdminUser> loginToken = (LoginToken<AdminUser>) ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
		return loginToken == null ? null : loginToken.getLoginUser();
	}
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:24,代碼來源:DefaultHttpAccessLoggingInterceptor.java

示例2: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
    if (parameter.hasParameterAnnotation(CurrentUser.class)) {
        return true;
    }
    return false;
}
 
開發者ID:aollio,項目名稱:school-express-delivery,代碼行數:8,代碼來源:CurrentUserMethodArgumentResolver.java

示例3: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * @return true if the parameter is annotated with {@link ModelAttribute}
 * or in default resolution mode also if it is not a simple type.
 */
@Override
public boolean supportsParameter(MethodParameter parameter) {
	if (parameter.hasParameterAnnotation(ModelAttribute.class)) {
		return true;
	}
	else if (this.annotationNotRequired) {
		return !BeanUtils.isSimpleProperty(parameter.getParameterType());
	}
	else {
		return false;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:ModelAttributeMethodProcessor.java

示例4: findSessionAttributeArguments

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * Return all {@code @ModelAttribute} arguments declared as session
 * attributes via {@code @SessionAttributes}.
 */
private List<String> findSessionAttributeArguments(HandlerMethod handlerMethod) {
	List<String> result = new ArrayList<String>();
	for (MethodParameter param : handlerMethod.getMethodParameters()) {
		if (param.hasParameterAnnotation(ModelAttribute.class)) {
			String name = getNameForParameter(param);
			if (this.sessionAttributesHandler.isHandlerSessionAttribute(name, param.getParameterType())) {
				result.add(name);
			}
		}
	}
	return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:ModelFactory.java

示例5: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * Supports the following:
 * <ul>
 * <li>@RequestParam-annotated method arguments.
 * This excludes {@link Map} params where the annotation doesn't
 * specify a name.	See {@link RequestParamMapMethodArgumentResolver}
 * instead for such params.
 * <li>Arguments of type {@link MultipartFile}
 * unless annotated with @{@link RequestPart}.
 * <li>Arguments of type {@code javax.servlet.http.Part}
 * unless annotated with @{@link RequestPart}.
 * <li>In default resolution mode, simple type arguments
 * even if not with @{@link RequestParam}.
 * </ul>
 */
@Override
public boolean supportsParameter(MethodParameter parameter) {
	Class<?> paramType = parameter.getParameterType();
	if (parameter.hasParameterAnnotation(RequestParam.class)) {
		if (Map.class.isAssignableFrom(paramType)) {
			String paramName = parameter.getParameterAnnotation(RequestParam.class).value();
			return StringUtils.hasText(paramName);
		}
		else {
			return true;
		}
	}
	else {
		if (parameter.hasParameterAnnotation(RequestPart.class)) {
			return false;
		}
		else if (MultipartFile.class.equals(paramType) || "javax.servlet.http.Part".equals(paramType.getName())) {
			return true;
		}
		else if (this.useDefaultResolution) {
			return BeanUtils.isSimpleProperty(paramType);
		}
		else {
			return false;
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:43,代碼來源:RequestParamMethodArgumentResolver.java

示例6: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
/**
 * 是否支持這個參數
 *
 * @param parameter
 * @return dummy
 */
@Override
public boolean supportsParameter(MethodParameter parameter) {
    // 有這兩個注解,就不支持
    if (parameter.hasParameterAnnotation(WxApiBody.class) || parameter.hasParameterAnnotation(WxApiForm.class)) {
        return false;
    }
    if (parameter.hasParameterAnnotation(annotationType)) {
        return true;
    } else {
        return BeanUtils.isSimpleProperty(parameter.getNestedParameterType());
    }
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:19,代碼來源:AbstractWxApiRequestContributor.java

示例7: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(ExcelRequestBody.class);
}
 
開發者ID:natsuforyou,項目名稱:spring-boot-excel-plugin,代碼行數:5,代碼來源:ExcelRequestResponseBodyHandler.java

示例8: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
}
 
開發者ID:zhaoqicheng,項目名稱:renren-fast,代碼行數:5,代碼來源:LoginUserHandlerMethodArgumentResolver.java

示例9: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(JsonParameter.class);
}
 
開發者ID:guqiyao,項目名稱:fishing-village,代碼行數:5,代碼來源:JsonParameterResolver.java

示例10: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.hasParameterAnnotation(WampSessionId.class);
}
 
開發者ID:ralscha,項目名稱:wamp2spring,代碼行數:5,代碼來源:WampSessionIdMethodArgumentResolver.java

示例11: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.hasParameterAnnotation(RequestHeader.class)
			&& Map.class.isAssignableFrom(parameter.getParameterType());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:6,代碼來源:RequestHeaderMapMethodArgumentResolver.java

示例12: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.hasParameterAnnotation(Value.class);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:ExpressionValueMethodArgumentResolver.java

示例13: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.hasParameterAnnotation(RequestHeader.class)
			&& !Map.class.isAssignableFrom(parameter.getParameterType());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:6,代碼來源:RequestHeaderMethodArgumentResolver.java

示例14: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.hasParameterAnnotation(CookieValue.class);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:AbstractCookieValueMethodArgumentResolver.java

示例15: supportsParameter

import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
public boolean supportsParameter(MethodParameter parameter) {
    return parameter.hasParameterAnnotation(JsonArg.class);
}
 
開發者ID:mingzuozhibi,項目名稱:mzzb-server,代碼行數:4,代碼來源:JsonArgumentResolver.java


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