此警告是 WebComponent 记录的唯一内容,因此只需将日志记录设置为 ERROR 级别或在 logback.xml 或您配置了日志记录的任何位置关闭此组件的日志记录。您无需编写自定义过滤器来忽略此特定消息,因为此组件没有记录其他消息。
org.glassfish.jersey.servlet.WebComponent 2.14 版的源代码片段:
if(!form.asMap().isEmpty()) {
containerRequest.setProperty("jersey.config.server.representation.decoded.form", form);
if(LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, LocalizationMessages.FORM_PARAM_CONSUMED(containerRequest.getRequestUri()));
}
}
用于此警告消息的本地化消息是:
form.param.consumed=A servlet request to the URI {0} contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
在 logback.xml 中关闭 WebComponent 的日志记录,如下所示:
<logger name="org.glassfish.jersey.servlet.WebComponent" level="OFF" additivity="false"/>