类 GlobalControllerAdvice

java.lang.Object
net.sohelp.boot.admin.core.advice.GlobalControllerAdvice
所有已实现的接口:
org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>

@ControllerAdvice public class GlobalControllerAdvice extends Object implements org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>
全局控制器增强处理类,用于统一处理响应数据 该类实现了ResponseBodyAdvice接口,可以在响应体写入之前进行统一处理 主要功能是根据操作日志服务的配置,决定是否清除ApiResult中的错误信息
从以下版本开始:
2024/08/20 10:20
作者:
AaronFung
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    beforeBodyWrite(Object body, org.springframework.core.MethodParameter returnType, org.springframework.http.MediaType selectedContentType, Class selectedConverterType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
    在响应体写入之前进行处理,主要功能是根据操作日志配置决定是否清除错误信息
    boolean
    supports(org.springframework.core.MethodParameter returnType, Class converterType)
    判断当前控制器方法是否支持响应体增强处理

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • GlobalControllerAdvice

      public GlobalControllerAdvice()
  • 方法详细资料

    • supports

      public boolean supports(@NotNull org.springframework.core.MethodParameter returnType, @NotNull Class converterType)
      判断当前控制器方法是否支持响应体增强处理
      指定者:
      supports 在接口中 org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>
      参数:
      returnType - 控制器方法的返回类型信息,包含方法签名、返回类型等元数据
      converterType - 消息转换器的类型,用于将返回值转换为HTTP响应
      返回:
      true表示支持所有控制器方法的响应体增强处理,false表示不支持
    • beforeBodyWrite

      public Object beforeBodyWrite(Object body, @NotNull org.springframework.core.MethodParameter returnType, @NotNull org.springframework.http.MediaType selectedContentType, @NotNull Class selectedConverterType, @NotNull org.springframework.http.server.ServerHttpRequest request, @NotNull org.springframework.http.server.ServerHttpResponse response)
      在响应体写入之前进行处理,主要功能是根据操作日志配置决定是否清除错误信息
      指定者:
      beforeBodyWrite 在接口中 org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<Object>
      参数:
      body - 控制器方法返回的响应体对象
      returnType - 控制器方法的返回类型信息
      selectedContentType - 选定的内容类型(MIME类型)
      selectedConverterType - 选定的消息转换器类型
      request - 当前的HTTP请求对象,包含请求URL、头部等信息
      response - 当前的HTTP响应对象,可用于设置响应头部等
      返回:
      处理后的响应体对象