简体   繁体   中英

Automatic view routing in playframework 2.0?

All of the examples of view rendering in play documentation I've seen so far required actually specifying a view and then making a render() call.

Is there a way to configure a default view for each action and then have the action automatically render the default view specified?

In play 2.0 the templates actually are functions that return instances of the class Html which the Actions then use to create a reply, this means that you must call them to get any output.

You might be able to create some reflection trixery to achieve what you describe but there is nothing like that built into play. I personally think that this is one of the really strong points of Play, allowing the compiler to check that all parameters for the templates are given and of the right type instead of getting runtime errors because some mapping or context-object were of the wrong type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM