播放1.2.5管理模块显示访问被拒绝

时间:2013-06-21 11:00:38

标签: playframework

这是我的代码:

1。应用程序只执行一些日志工作。

public class Application extends CRUD {

}

2。用户是我想要编辑的模型,所以我有一个用户作为控制器:

public class Users extends Application {

}

3。路线:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET     /                                       Application.index

# Ignore favicon requests
GET     /favicon.ico                            404

# Map static resources from the /app/public folder to the /public path
GET     /public/                                staticDir:public

# Import CRUD routes
*      /admin                                   module:crud

# Catch all
*       /{controller}/{action}                  {controller}.{action}

然后我关注localhost:9000/admin,显示404无法找到页面:

These routes have been tried, in this order :

GET       /@documentation/cheatsheet/{category}             PlayDocumentation.cheatSheet
GET       /@documentation/modules/{module}/files/{name}     PlayDocumentation.file
GET       /@documentation/modules/{module}/images/{name}    PlayDocumentation.image
GET       /@documentation/modules/{module}/{id}             PlayDocumentation.page
GET       /@documentation/files/{name}                      PlayDocumentation.file
GET       /@documentation/images/{name}                     PlayDocumentation.image
GET       /@documentation/{id}                              PlayDocumentation.page
GET       /@documentation/?                                 PlayDocumentation.index
GET       /                                                 Application.index
GET       /favicon.ico                                      404
GET       /public/                                          staticDir:public
GET       /admin/                                           CRUD.index
*         /{controller}/{action}                            {controller}.{action}

然后我添加了一个slu localhost:9000/admin/

事实证明访问被拒绝了!

我该如何处理?

2 个答案:

答案 0 :(得分:0)

crud控制器需要以你的实体命名。如果它应该管理名为User的实体,则需要将其命名为Users。或者它可以有一个@ CRUD.For注释,它指定它应该管理的实体。由于您的控制器既不匹配命名约定也没有@ CRUD.For注释,Play将会遇到问题。

你的扩展类看起来也错了。如果你说你的模型被命名为“用户”,它应该扩展“模型”而不是“应用程序”。所以例如如果您的模型名为Users,它应该如下所示。

public class Users extends Model {

... 

}

@CRUD.For(Users.class)
public class UserAdmin extends CRUD {

}

在相关的说明中,我会调用User模型用户,因为它代表一个用户。

答案 1 :(得分:0)

尝试使用@With注释,而不是扩展Application:

@With(Application.class)
@CRUD.For(User.class)
public class Users extends CRUD {
}