Spring webflow 阻止转换中的 GET 方法

Spring webflow prevent GET method in transition

我在我的项目中使用 spring webflow 2.3.1.RELEASE。

客户的安全团队提出问题 是 "It is possible to change the http method from POST to GET and the application accepts the change and continues working."

所以我需要阻止这种变化,让我的转换只接受 POST 方法。或者如果我在 url.

中得到除执行之外的任何请求参数,则抛出异常

我该怎么做?

您可以创建自己的 FlowExecutionListener 并在请求方法不同于 POST 时抛出异常 and/or 当存在请求参数时。

查看文档here and API here

我使用 FlowHandlerMapping 的拦截器解决了这个问题。

我创建了一个 class 并将其命名为 MethodInterceptor, implementend org.springframework.web.context.request.WebRequestInterceptor.

在"public void preHandle(WebRequest request) throws Exception"方法中,我检查了请求方法,如果是get,我检查了请求参数为空或仅包含执行参数。如果条件不满足,我抛出异常。