當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。