使用Spring WebFlow的Apache Tiles通配符 [英] Apache Tiles wildcard with Spring WebFlow

查看:109
本文介绍了使用Spring WebFlow的Apache Tiles通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Tiles 2.1.3具有通配符功能,其中tile定义包括一个星号:

Apache Tiles 2.1.3 has a wildcard feature where a tiles definition includes an asterisk:

<definition name="flow/*" extends=".mainTemplate">
    <put-attribute name="header" value="/WEB-INF/jsp/header.jsp"  />
    <put-attribute name="body" value="/WEB-INF/jsp/flow/{1}.jsp"  />
</definition>

此处进行了说明,但基本上这种布局是用于流"目录中的任何JSP.

It's explained here, but basically this layout is used for any JSP in the "flow" directory.

问题是Spring Webflow使用Tiles产生了无限递归:

The problem is Spring Webflow produced infinite recursion with Tiles:

org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'createAccount' of flow 'jsp/flow'
Caused by: java.lang.IllegalStateException: Exception occurred rendering view null
Caused by: java.lang.NullPointerException

我最终插入了许多单独的Tiles定义,而不是一个通配符定义(在此处插入皱眉).

I wound up inserting many individual Tiles definitions instead of one wildcarded definition (insert frowny face here).

Tiles通配符如何与Spring WebFlow一起使用?

How does Tiles wildcards work with Spring WebFlow?

推荐答案

简单修复:您不能将默认的Web Flow视图名称与通配符一起使用,因为您无法创建像这样的通配Tiles定义:

Simple fix: You cannot use the default Web Flow view names with wildcarding because you cannot create a wildcard Tiles definition like this:

<definition name="*" extends=".flowTemplate">
    <put-attribute name="header" value="/WEB-INF/jsp/header.jsp"  />
    <put-attribute name="body" value="/WEB-INF/jsp/flow/{1}.jsp"  />
</definition>

如果您提供像这样的纯"*"定义,则Tiles系统将进入(看似)无限循环:

The Tiles system goes into a (seemingly) infinite loop if you provide a pure "*" definition like this:

name="*" 

执行此操作的方法是提供如下定义:

The way to do this is to provide a definition like this:

<definition name="flow/*" extends=".flowTemplate">
    <put-attribute name="header" value="/WEB-INF/jsp/header.jsp"  />
    <put-attribute name="body" value="/WEB-INF/jsp/flow/{1}.jsp"  />
</definition>

然后将您的Web Flow视图名称强制为该格式,如下所示:

And then force your Web Flow view names to that form, like so:

<view-state id="myView" model="myView" view="flow/myView">
    <transition on="back" to="previousView" />
    <transition on="next" to="nextView" />
</view-state>

默认视图名称是视图ID,在这种情况下为"myView".您不能为视图指定ID为"flow/myView",但可以使用

The default view name is the view id, in this case "myView". You can't give your view an id of "flow/myView" but you can specify the view name separately with

view="flow/myView"

,这会将正确的值提供给Tiles解析器.我敢肯定,Tiles视图命名和Web Flow视图分辨率还会有其他问题,但这解决了我的问题.

and that will feed the correct value to the Tiles resolver. I'm sure that there are additional wrinkles to Tiles view naming and Web Flow view resolution, but this solved my problem.

请确保引用正确的网址(即,适当地注入"flow/").

Be sure to reference the correct URL (i.e., inject "flow/" as appropriate).

这篇关于使用Spring WebFlow的Apache Tiles通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆