如何在SpringWebFlow的validate方法中获取httpServletRequest

时间:2013-06-04 15:23:15

标签: spring-webflow

我需要在spring webflow的validate方法中访问httpServletRequest。请帮我解决这个问题。

我的观看状态的网络流程是:

    <var name="search" class="com.test.form.Search"/>
...................
    <view-state id="search" model="search" view="searchPage"> 
            <transition on="submit" to="searchAction">
            </transition>
        </view-state>
...............
搜索模型类中的

验证方法是:

public void validateLoanSearch(ValidationContext context) {
//I need to get a httpServletRequest here...
}

在action / controller类中,我可以通过RequestContext获取它,但ValidationContext只提供messageContext。任何的想法?请帮忙。

1 个答案:

答案 0 :(得分:3)

我得到了解决方案。

在validate方法中的bean类或validator类中使用:

RequestContext rc = RequestContextHolder.getRequestContext();

RequestContextHolder在validate方法中可用。

相关问题