我想在我的应用程序中实现 CommonsRequestLoggingFilter 并将请求和响应获取到 Java 代码中:
@Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter();
loggingFilter.setIncludeClientInfo(true);
loggingFilter.setIncludeQueryString(true);
loggingFilter.setIncludePayload(true);
loggingFilter.setIncludeHeaders(false);
return loggingFilter;
}
如何将有效负载放入 Rest 控制器代码?例子:
@RestController
public class LoggingDemoController {
@GetMapping("/demo/greeting")
public String sayHello(){
// Get here the payload from CommonsRequestLoggingFilter
return "Hello Stranger !!!";
}
}
这可能吗?