作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我使用Play 1.2时,我可以使用@Before或@After(以及其他...)在任何 Controller 内注释一些方法,以便在此 Controller 内的每个请求之前或之后执行一个方法。
如何在Play 2.0中做到这一点?
我读了一些有关Global对象的信息,但这似乎不是我想要的。另外, Action 组合对于我想做的事情似乎太复杂了。我希望看到更简单的东西。
有任何想法吗?
最佳答案
不幸的是,您必须将action composition用作@Before
,而@After
没有等效项。
对于@After
,我将在end操作结束时编写自己的after
方法;像这样的东西:
public static Result index() {
....
Result result = ...;
return after(result);
}
protected static Result after(Result result) {
...
Result afterResult = ...,
return afterResult
}
关于playframework-2.0 - Play 1.2中@Before和@After的Play 2.0等效项是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12683176/
我是一名优秀的程序员,十分优秀!