当前位置: 首页>>代码示例>>Java>>正文


Java MethodParameter.getMethodAnnotation方法代码示例

本文整理汇总了Java中org.springframework.core.MethodParameter.getMethodAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java MethodParameter.getMethodAnnotation方法的具体用法?Java MethodParameter.getMethodAnnotation怎么用?Java MethodParameter.getMethodAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.MethodParameter的用法示例。


在下文中一共展示了MethodParameter.getMethodAnnotation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforeBodyWrite

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
                              Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request,
                              ServerHttpResponse response) {

    ResponseJSONP responseJsonp = returnType.getMethodAnnotation(ResponseJSONP.class);
    if(responseJsonp == null){
        responseJsonp = returnType.getContainingClass().getAnnotation(ResponseJSONP.class);
    }

    HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();
    String callbackMethodName = servletRequest.getParameter(responseJsonp.callback());

    if (!IOUtils.isValidJsonpQueryParam(callbackMethodName)) {
        if (logger.isDebugEnabled()) {
            logger.debug("Invalid jsonp parameter value:" + callbackMethodName);
        }
        callbackMethodName = null;
    }

    JSONPObject jsonpObject = new JSONPObject(callbackMethodName);
    jsonpObject.addParameter(body);
    beforeBodyWriteInternal(jsonpObject, selectedContentType, returnType, request, response);
    return jsonpObject;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:JSONPResponseBodyAdvice.java

示例2: handleReturnValue

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
    HttpServletResponse servletResponse = webRequest.getNativeResponse(HttpServletResponse.class);

    ExcelResponseBody annotation = returnType.getMethodAnnotation(ExcelResponseBody.class);
    ExcelType type = annotation.type();
    String fileName = annotation.name() + type.suffixName();

    servletResponse.setContentType("application/vnd.ms-converter");
    servletResponse.setHeader("content-disposition", "attachment;filename=" + fileName);
    List<?> excel;
    if (returnValue instanceof List) {
        excel = (List<?>) returnValue;
    } else {
        excel = Collections.singletonList(returnValue);
    }

    if (converters.supportsExcelType(type)) {
        try (Workbook workbook = converters.toExcel(annotation, excel)) {
            workbook.write(servletResponse.getOutputStream());
            servletResponse.flushBuffer();
        } catch (IOException ignored) {
            ;
        }
    }


}
 
开发者ID:natsuforyou,项目名称:spring-boot-excel-plugin,代码行数:29,代码来源:ExcelRequestResponseBodyHandler.java

示例3: supportsReturnType

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
/**
 * Return {@code true} if there is a method-level {@code @ModelAttribute}
 * or if it is a non-simple type when {@code annotationNotRequired=true}.
 */
@Override
public boolean supportsReturnType(MethodParameter returnType) {
	if (returnType.getMethodAnnotation(ModelAttribute.class) != null) {
		return true;
	}
	else if (this.annotationNotRequired) {
		return !BeanUtils.isSimpleProperty(returnType.getParameterType());
	}
	else {
		return false;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ModelAttributeMethodProcessor.java

示例4: supportsParameter

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.getMethodAnnotation(UserInfoOauth.class) != null;
}
 
开发者ID:tojaoomy,项目名称:private-WeChat,代码行数:5,代码来源:SNSUserInfoArgumentResolver.java

示例5: supportsParameter

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.getMethodAnnotation(BaseOauth.class) != null;
}
 
开发者ID:tojaoomy,项目名称:private-WeChat,代码行数:5,代码来源:Oauth2TokenArgumentResolver.java

示例6: supportsParameter

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.getMethodAnnotation(UserInfoOauth.class) != null;
}
 
开发者ID:tojaoomy,项目名称:private-WeChat,代码行数:4,代码来源:SNSUserInfoArgumentResolver.java

示例7: supportsParameter

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.getMethodAnnotation(BaseOauth.class) != null;
}
 
开发者ID:tojaoomy,项目名称:private-WeChat,代码行数:4,代码来源:Oauth2TokenArgumentResolver.java

示例8: resolves

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean resolves(MethodParameter parameter) {
    return parameter.getMethodAnnotation(RequestMapping.class) != null
            && parameter.getParameterAnnotation(PathVariable.class) != null;
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:6,代码来源:PathVariableArgumentResolver.java

示例9: supportsReturnType

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
public boolean supportsReturnType(MethodParameter returnType) {
    return returnType.getMethodAnnotation(JsonBody.class) != null;
}
 
开发者ID:didapinchegit,项目名称:rocket-console,代码行数:4,代码来源:JsonBodyReturnValueProcessor.java

示例10: getNameForReturnValue

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
/**
 * Derive the model attribute name for the given return value using
 * one of the following:
 * <ol>
 * 	<li>The method {@code ModelAttribute} annotation value
 * 	<li>The declared return type if it is other than {@code Object}
 * 	<li>The actual return value type
 * </ol>
 * @param returnValue the value returned from a method invocation
 * @param returnType the return type of the method
 * @return the model name, never {@code null} nor empty
 */
public static String getNameForReturnValue(Object returnValue, MethodParameter returnType) {
	ModelAttribute annot = returnType.getMethodAnnotation(ModelAttribute.class);
	if (annot != null && StringUtils.hasText(annot.value())) {
		return annot.value();
	}
	else {
		Method method = returnType.getMethod();
		Class<?> resolvedType = GenericTypeResolver.resolveReturnType(method, returnType.getContainingClass());
		return Conventions.getVariableNameForReturnType(method, resolvedType, returnValue);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ModelFactory.java


注:本文中的org.springframework.core.MethodParameter.getMethodAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。