试行在游戏教程中的自定义编辑器部分,我创建了路线如下playframework问题的路线:NoRouteFoundException
GET /admin/myPosts/{id} Admin.form
GET /admin/new Admin.form
POST /admin/new Admin.save
GET /admin? Admin.index
* /admin module:crud
开创了管理类中的方法
..
public static void form() {
logger.info("Admin.form()");
render();
}
public static void save(String title,String content,String tags) {
User author = User.find("byEmail",Security.connected()).first();
logger.info("author="+author.getEmail());
//create a post
Post newPost = new Post(author,title,content);
logger.info("new post="+newPost.getTitle()+" created");
//set tags
String[] tagArray = tags.split("\\s+");
logger.info("tag array="+tagArray.length);
for(String tag : tagArray) {
logger.info("tag="+tag);
if(tag.trim().length() > 0) {
newPost.getTags().add(Tag.findOrCreateByName(tag));
}
}
validation.valid(newPost);
if(validation.hasErrors()) {
logger.error("error in post");
render("@form", newPost);
}
newPost.save();
logger.info("new post saved");
logger.info("going to index");
index();
}
public static void form(Long id) {
if(id!=null) {
Post post = Post.findById(id);
render(post);
}
render();
}
...
的意见/管理员/index.html是
3210当我点击登录时,包含链接的行???原因
Internal Server Error (500) for request GET /admin?
No route found (In /app/views/Admin/index.html around line 7)
No route able to invoke action Admin.form was found.
play.exceptions.NoRouteFoundException: No route found
at play.templates.BaseTemplate.throwException(BaseTemplate.java:80)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:237)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:184)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:659)
at play.mvc.Controller.renderTemplate(Controller.java:639)
at play.mvc.Controller.render(Controller.java:694)
at controllers.Admin.index(Admin.java:33)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:543)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:499)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:475)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:470)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:158)
at Invocation.HTTP Request(Play!)
如何解决这个问题谁能帮是否有在路由路径的顺序有问题的crud and secure
模块可按照启动消息
更新: 堆栈跟踪通过发挥出在这里
我试图改变路由条目顺序file..Put的* /admin path before GET/admin? as below
..Now我摹ETTING一个奇怪的渲染页面
GET /admin/myPosts/{id} Admin.form
GET /admin/new Admin.form
POST /admin/new Admin.save
* /admin module:crud
GET /admin? Admin.index
这是在登录时,鲍勃@ gmail的结束了! 对于网址http://localhost:9000/admin?
,页面应显示MyPosts链接为选中..但在这里的评论链接显示为选中。
因此,它必须是与路径文件中的路径顺序问题...特别是那个* /admin?
..有人能告诉我它应该放在哪里吗?
有在routes文件一个小问题(缺少/) 完整路径文件
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
#import crud routes
GET /admin/myPosts/{id} Admin.form
GET /admin/new Admin.form
POST /admin/myPosts/{id} Admin.save
POST /admin/new Admin.save
GET /admin/? Admin.index
* /admin module:crud
# Home page
GET / Application.index
# details of a post
GET /posts/{<[0-9]+>id} Application.showPost
GET /captcha Application.captcha
GET /posts/{tag} Application.taggedWith
POST /posts/{<[0-9]+>id}/comments Application.postComment
# Ignore favicon requests
GET /favicon.ico 404
# Map static resources from the /app/public folder to the /public path
GET /public/ staticDir:public
# Catch all
# Import Secure routes
* / module:secure
* /{controller}/{action} {controller}.{action}
管理页面正常显示,当我忽略index.html中
#{list items:posts,as:'post' }
<p class="post ${post_parity}">
${post_index}.<a href="#">${ post.title}</a>
</p>
#{/list}
<p id="newPost">
<a href="@{Admin.form()}"><span>+</span>write new post</a>
</p>
的
Admin.form(post.id)
链接
一旦链接添加
#{list items:posts, as:'post'}
<p class="post ${post_parity}">
<a href="@{Admin.form(post.id)}">${post.title}</a>
</p>
#{/list}
No route able to invoke action Admin.form was found
错误信息发生
您的CRUD路由应该接近尾声,因为如果它在开始位置,那么所有其他路由都将不起作用,因为路由文件被读入订购。如果您将CRUD路线置于顶部,则会在找到任何其他/管理路线之前拦截路线。 – Codemwnci
你有你的路线文件中的所有路线吗? – Codemwnci
感谢您的帮助..你的评论帮了我很多 –