How to fix Jersey POST request parameters warning?

后端 未结 9 911
暗喜
暗喜 2020-12-08 06:50

I\'m building a very simple REST API using Jersey, and I\'ve got a warning in my log files that I\'m not sure about.

WARNING: A servlet POST request,

9条回答
  •  死守一世寂寞
    2020-12-08 07:25

    This message is meant to warn developers about the fact that the request entity body has been consumed, thus any other attempts to read the message body will fail.

    It is safe to ignore the message or filter it out from the logs:

    java.util.logging.Logger jerseyLogger =
            java.util.logging.Logger.getLogger(WebComponent.class.getName());
    jerseyLogger.setFilter(new Filter() {
        @Override
        public boolean isLoggable(LogRecord record) {
            boolean isLoggable = true;
            if (record.getMessage().contains("Only resource methods using @FormParam")) {
                isLoggable = false;
            }
            return isLoggable;
        }
    });
    

提交回复
热议问题