grails - 重写 Controller 中默认操作的 URL

标签 grails url-rewriting url-mapping grails-controller

我在 Grails 中重写 URL 时遇到问题:

我有 2 个 Controller BlogControllerProjectsController,每个 Controller 都有一个默认的 def index = { } 和匹配的 View 。

现在当我创建以下链接时:

<g:link controller="blog">Blog</g:link>
<g:link controller="projects">Projects</g:link>

它们被翻译为http://localhost:8080/myapp/blog/indexhttp://localhost:8080/myapp/projects/index。但希望它们(以及所有其他 Controller 的默认操作)没有尾随 /index

谁能帮我做这个吗?

最佳答案

尝试将 link 标记中的 action 参数指定为空格。

<g:link controller="projects" action=" ">Projects</g:link>

关于grails - 重写 Controller 中默认操作的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3470490/

相关文章:

grails - 在 Grails 应用程序和非 Grails 应用程序之间共享域对象

php - .htaccess 用 gif url 中的参数重写 url

Grails - 使用命名编码器的单元测试 Controller

tomcat - 在 Tomcat 中杀死守护线程的方法,应用程序无法启动 - 你如何解决这个问题?

hibernate - Grails、GPars 和数据持久性

.htaccess 将目录重定向到单个页面

spring-boot - 如何阻止 Spring Boot 添加 session cookie?

rest - Grails REST Controller 显示get的删除操作

grails - 在 Grails 应用程序中创建 "pretty"用户配置文件 URL

grails - Grails URL映射多个 View