2013-06-04 15 views
2

的validate方法獲得的HttpServletRequest我需要訪問HttpServletRequest的春天的Webflow的validate方法。請幫助我如何做到這一點。如何SpringWebFlow

我的視圖狀態的Webflow是:在搜索模型類

<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方法是:

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

在動作/控制器類我可以讓它直通的RequestContext但ValidationContext只給出的MessageContext 。任何想法?請幫忙。

回答

2

我得到了解決。

在bean類或驗證器類validate方法使用這裏面:

RequestContext rc = RequestContextHolder.getRequestContext(); 

RequestContextHolder被驗證方法內變得可用。