【问题标题】:How to obtain httpServletRequest in validate method of SpringWebFlowSpringWebFlow的validate方法中如何获取httpServletRequest
【发布时间】:2013-05-31 01:46:17
【问题描述】:

我需要在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...
}

在动作/控制器类中,我可以通过 RequestContext 获取它,但 ValidationContext 只提供消息上下文。任何想法?请帮忙。

【问题讨论】:

    标签: spring-webflow


    【解决方案1】:

    我找到了解决方案。

    在 bean 类或验证器类里面的 validate 方法中使用这个:

    RequestContext rc = RequestContextHolder.getRequestContext();
    

    RequestContextHolder 在 validate 方法中变得可用。

    【讨论】:

      猜你喜欢
      • 2012-08-21
      • 1970-01-01
      • 2010-10-31
      • 1970-01-01
      • 2019-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-17
      相关资源
      最近更新 更多