3

I need to access httpServletRequest in the validate method of spring webflow. Please help me how to do this.

My webflow for view state is:

    <var name="search" class="com.test.form.Search"/>
...................
    <view-state id="search" model="search" view="searchPage"> 
            <transition on="submit" to="searchAction">
            </transition>
        </view-state>
...............

validate method in search model class is:

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

In action/controller class I can get it thru RequestContext but ValidationContext gives only the messageContext. Any idea? Please help.

4

1 回答 1

3

我得到了解决方案。

在 validate 方法内的 bean 类或验证器类中使用:

RequestContext rc = RequestContextHolder.getRequestContext();

RequestContextHolder 在 validate 方法中变得可用。

于 2013-06-27T18:07:33.753 回答