本文整理汇总了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);
}
}