本文介绍了如何修复Jersey POST请求参数警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Jersey建立一个非常简单的REST API,并且在我的日志文件中有一个我不确定的警告.
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.
我的Web应用程序仅定义了Jersey servlet,映射到/myapi/*
My webapp only has the Jersey servlet defined, mapped to /myapi/*
如何停止这些警告?
推荐答案
对我来说,警告显示为POST application/x-www-form-urlencoded.而且我正在使用Spring Boot,它具有一个HiddenHttpMethodFilter,它在执行其他操作之前先执行getParameter.所以我最终做了这个讨厌的重写:
For me the warning was showing for POST application/x-www-form-urlencoded. And I am using Spring Boot which has an HiddenHttpMethodFilter that does a getParameter before anything else... So I ended up doing this nasty override:
@Bean
public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
return new HiddenHttpMethodFilter() {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
if ("POST".equals(request.getMethod())
&& request.getContentType().equals(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) {
filterChain.doFilter(request, response);
} else {
super.doFilterInternal(request, response, filterChain);
}
}
};
}
这篇关于如何修复Jersey POST请求参数警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!