加个这个类就可以了
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
@Component
public class LoggingFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
System.out.println("Request URL: " + httpRequest.getRequestURL());
StringBuilder requestBody = new StringBuilder();
BufferedReader reader = httpRequest.getReader();
String line;
while ((line = reader.readLine()) != null) {
requestBody.append(line).append('\n');
}
System.out.println("Request Body: " + requestBody);
chain.doFilter(request, response);
}
}