【问题标题】:can spring webflow handle a dynamic expression inside "evaluate" tag?spring webflow 可以处理“评估”标签内的动态表达式吗?
【发布时间】:2016-04-07 02:59:50
【问题描述】:

我看到在spring webflow中你可以对视图使用动态表达式

<view-state id="error" view="error-#{externalContext.locale}.xhtml" />

我可以对评估做同样的事情吗?比如:

 <evaluate expression="#{variable}Controller.processData()" />

提前感谢您的帮助。

【问题讨论】:

    标签: spring spring-webflow spring-webflow-2


    【解决方案1】:

    这是一个想法:

    <evaluate expression="webFlowUtil.getBean(variable.concat('Controller'))" result="flowScope.controller"/>
    

    @Component
    public class WebFlowUtil {
    
        @Autowired
        private ApplicationContext applicationContext;
    
        public Object getBean(String beanName) {
            return applicationContext.getBean(beanName);
        }
    }
    

    以后再用

    <evaluate expression="controller.processData()" />
    

    【讨论】:

    • 感谢您的想法。我认为这是一个很好的解决方法,但答案仍然是“不,表达式中的值不会被评估”
    【解决方案2】:

    让我回答我自己的问题:不,这是不可能的。根据spring webflow的xsd:

    <xsd:attribute name="expression" type="expression" use="required">
    

    在哪里

    <xsd:simpleType name="expression">
        <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    
    <xsd:simpleType name="template">
        <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    

    根据文档,表达式应该是“模板”类型,以便对其进行评估。

    【讨论】:

      猜你喜欢
      • 2011-08-08
      • 2016-03-18
      • 1970-01-01
      • 2012-09-05
      • 1970-01-01
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多