当前位置: 首页>>代码示例>>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;未经允许,请勿转载。