本文整理匯總了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;
}
示例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) {
;
}
}
}
示例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;
}
}
示例4: supportsParameter
import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getMethodAnnotation(UserInfoOauth.class) != null;
}
示例5: supportsParameter
import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getMethodAnnotation(BaseOauth.class) != null;
}
示例6: supportsParameter
import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getMethodAnnotation(UserInfoOauth.class) != null;
}
示例7: supportsParameter
import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getMethodAnnotation(BaseOauth.class) != null;
}
示例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;
}
示例9: supportsReturnType
import org.springframework.core.MethodParameter; //導入方法依賴的package包/類
public boolean supportsReturnType(MethodParameter returnType) {
return returnType.getMethodAnnotation(JsonBody.class) != null;
}
示例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);
}
}