You can register and use an Interceptor
that will catch all the requests to the app, if the method is other than GET/POST, simply redirect to an error page of your choosing / send an error response.
public class MyInterceptor extends HandlerInterceptorAdapter{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!request.getMethod().equalsIgnoreCase("POST") && !request.getMethod().equalsIgnoreCase("GET")) {
// Not a POST/GET - send error and return false
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Unauthorized Request");
return false;
} else {
return true;
}
}
}
to register the interceptor, add this to your spring xml configuration file
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="your.package.MyInterceptor" />
</mvc:interceptor>
</mvc:interceptors>