本文整理汇总了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();
}
}
示例2: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
if (parameter.hasParameterAnnotation(CurrentUser.class)) {
return true;
}
return false;
}
示例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;
}
}
示例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;
}
示例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;
}
}
}
示例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());
}
}
示例7: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(ExcelRequestBody.class);
}
示例8: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
}
示例9: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(JsonParameter.class);
}
示例10: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(WampSessionId.class);
}
示例11: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(RequestHeader.class)
&& Map.class.isAssignableFrom(parameter.getParameterType());
}
示例12: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(Value.class);
}
示例13: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(RequestHeader.class)
&& !Map.class.isAssignableFrom(parameter.getParameterType());
}
示例14: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(CookieValue.class);
}
示例15: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(JsonArg.class);
}