what exactly does the @with annotation do? (Play Framework)

后端 未结 2 1193
梦谈多话
梦谈多话 2020-12-31 21:42

I don\'t quite understand what the @with annotation does.

in the Play framework site, it is written :

we can annotate the controllers using t

2条回答
  •  梦谈多话
    2020-12-31 22:20

    The best way I can describe it, is that it kind of gives you multiple inheritance at your controller level for your interceptors. Interceptors being the @Before, @After annotations.

    You could therefore

    • define a controller that dealt with your secure area @Before annotations
    • define a controller that dealt with injecting your static data for shared actions using @Before

    you could then define a controller or controllers that contained all your actions, and use the @With annotation to make use of the two controllers described above. It means you can separate your code out cleanly, and not have to rely on inheritance to execute the @Before annotations.

提交回复
热议问题