2016-11-16 46 views
0

我想包括一個枚舉添加枚舉訪問Spring WebFlow

public enum ContactType { 
    PHONE, 
    FAX, 
    MAIL 
} 

flow.xml有在視圖的訪問,並在流動本身。我試圖將其添加爲VAR(如豆腐):

<var name="ContactType" class="my.package.common.util.ContactType"/> 

但我得到的錯誤:

NoSuchMethodException: my.package.common.util.ContactType.<init>() 

我應該init()枚舉以某種方式?或者可能有另一種方法來包含它?

+0

你嘗試HTTP://forum.spring。 IO /論壇/ Spring的項目/網絡/的Webflow/78197-枚舉常量功能於Webflow的表達語言? –

+0

你正在使用哪個EL?春季EL? OGNL? – rptmat57

+0

@ rptmat57 Spring EL – joc

回答

0

您可能需要按照這種方式進行操作。不是最好的,但應與你的小枚舉集工作:

<evaluate expression="T(my.package.common.util.ContactType).PHONE" result="conversationScope.phoneContactType"/> 
<evaluate expression="T(my.package.common.util.ContactType).FAX" result="conversationScope.faxContactType"/> 
<evaluate expression="T(my.package.common.util.ContactType).MAIL" result="conversationScope.mailContactType"/> 

希望這對你的作品 - 其他@ rptmat57解決上述應予以考慮。

參考:http://forum.spring.io/forum/spring-projects/web/web-flow/78197-enum-constants-in-webflow-expression-language