在play2.2.1 java中找不到符号@Before

时间:2014-11-20 07:43:10

标签: java playframework controller interceptor

我正在尝试在我的控制器中使用@Before拦截器

 @Before(only = {"save" })
 static void parseParams() {
    String[] jobcategories = params.getAll("jobcategories");
    for (int i = 0; i < jobcategories.length; i++) {
        params.put("jobcategories[" + i + "].id", jobcategories[i]);
    }
    System.out.print(jobcategories);
 }

但是它给了我编译时错误

 C:\myapp\app\controllers\JobAdController.java:57: error: cannot find symbol
     @Before(only={"save"})
      ^
   symbol:   class Before
   location: class JobAdController
 C:\myapp\app\controllers\JobAdController.java:59: error: cannot find symbol
         String[] jobcategories = params.getAll("jobcategories");
                                  ^
   symbol:   variable params
   location: class JobAdController
 C:\myapp\app\controllers\JobAdController.java:61: error: cannot find symbol
             params.put("jobcategories["+i+"].id",jobcategories[i]);
             ^
   symbol:   variable params
   location: class JobAdController
 Note: Some input files use unchecked or unsafe operations.
 Note: Recompile with -Xlint:unchecked for details.
 3 errors
 (compile:compile) javac returned nonzero exit code
 Total time: 30 s, completed Nov 20, 2014 1:05:18 PM

我错过了什么?

1 个答案:

答案 0 :(得分:0)

你无法找到它来自Play 1.x API @Before,其他拦截器在Play 2.x中不可用 - 它们被Action Composition取代

@See similar topic

注意:根本不要使用Play 1.x的文档来播放2.x.在大多数地区,他们完全不同。