开发者

Suggestions for simple StringTemplate view resolution in Spring Web MVC app?

I'm migrating my Spring MVC app from a Tiles/EL view resolution setup to a StringTemplate view resolution setup. From my investigation so far I've gathered there are 2 possible approaches:

1) For each view that needs to be resolved, have 1 file which handles layout, i.e:

$layout/layout(content=exampleContent())$

and another file which actually provides the content (exampleContent() above):

<h1>Hello world!</h1>

<a href="#">This a link</a>

This approach seems simple enough, but it's annoying that for most views that we would have to create 2 files. Ideally we would like for most views to only require creating 1 file.

2) The other approach would be to use StringTemplateGroups. I'm not very familiar with them yet, but it seems like they could be used for handling layout resolution. This is a little bit less appealing to me than the above approach because not only would we have to edit 2 files for each view, but on top of that the 2 files would require learning StringTemplateGroup syntax in addition to basic StringTemplate syntax. I'd prefer to keep the learning curve as flat as possible and the cognitive load as low as possible.

Thoughts? Am I totally off-base about StringTemplateGroups? Is there an even simpler solution that I don't know about? Thanks for any feedback开发者_StackOverflow社区 :)


If you used a clever view resolution strategy you would only ever need to update the string template group files. If the logical view name was set to "path/to/stringtemplate/file/desiredtemplate" you could extract the stringtemplate file name, the desired template and populate the attributes from the Model.

It sounds like StringTemplateGroup is your best bet with a web app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜