0
が欠落している要求を拒否しますヘッダーのこれは実現可能ですか?春は、私は次の宣言を持っているベンダーのヘッダー(カスタムMIMEタイプ)
が欠落している要求を拒否しますヘッダーのこれは実現可能ですか?春は、私は次の宣言を持っているベンダーのヘッダー(カスタムMIMEタイプ)
あなたは以下のようHandlerInterceptor
を実装することで、特定の要求フィルタリングすることができます:
RequestMethodInterceptorクラス:
public class RequestMethodInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
//Get the 'Accept' header value
String headerValue = request.getHeader("Accept");
//check the request contains expected header value
if(!headerValue.equals("application/vnd.woot4moo-v1+json")) {
//Reject and Log or Ignore upon your requirement & return false
return false;
} else {
return true;
}
}
}
XML構成:
<mvc:interceptors>
<bean class="xyz.RequestMethodInterceptor" />
</mvc:interceptors>
を