我試圖做到這一點對我流的一個:Spring Webflow:如何將bean從控制器傳遞到流? (使用輸入映射)
<!-- Initial inputs -->
<input name="profileId" required="true" type="long" />
<input name="profile" required="true" type="com.myapp.model.Profile" />
冗餘的,我知道。這只是爲了調試目的
這裏的問題是配置文件爲空(com.myapp.model.Profile),由於所需的屬性錯誤引發異常到我的流程處理程序。 但是,profileId(長)不爲空,並且正常工作。
我的問題:
有沒有一種可能性,即類型不能是僅僅只有一個長型? (Here是另一個相關主題)
這裏是我的控制器:
@RequestMapping(value = "/mappingUrl", method = {RequestMethod.POST})
public String go2Flow(.... some parameters ...,
@ModelAttribute("profile") Profile profile,
ModelMap model) {
model.put("profile", profile);
model.put("profileId", profile.getId());
return "redirect:/app/myFlow";
}
編輯:
我解決它。由於我在我的Spring MVC控制器上使用@SessionAttributes作爲對象配置文件(名爲'profile'),所以在我的流程中,我只使用ExternalContext API檢索該對象。
因此,控制器保持相同的代碼,但我流的ExternalContext API可用於這樣的:
<on-start>
<evaluate expression="someService.serviceMethod(externalContext)" result="flowScope.outputVariable" />
</on-start>
,然後在服務方法:
@Override
public SomeObject serviceMethod(ExternalContext externalContext) {
Profile profile = (Profile) externalContext.getSessionMap().get("profile");
.....
(method logic)
.....
}
它的怪異,你包的名字中有一個大寫字母 –
對此深感抱歉。這不是真正的包名。這只是一個例子(一個糟糕的例子,也許是XD)。 – solaris98
修復了軟件包名稱。一個問題中不必要的奇怪東西往往會分散人們的注意力。 –