验证方式:curl -v -X TRACE ip:port,或使用其他接口调试工具如Postman
响应:状态行405 Method Not Allowed
且响应体无内容
方案一:使用过滤器
若webserver是tomcat, 添加过滤器的方式有很多
@Component
public class TraceHttpMethodFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
if (HttpMethod.TRACE.matches(request.getMethod()