【问题标题】:different mapping for the same url同一网址的不同映射
【发布时间】:2011-08-11 05:17:42
【问题描述】:

当用户登录 (session.user) 时,我想为相同的 url http://localhost:8080/myapp/ 使用不同的映射

实际上,默认情况下,我m giving the path when the url is "/" to AppController and 'index' action... but if I try to redirect inside the index action when the user is logged to my UserController (also index action), the path changes to @987654322@ . Thats 不是我要找的。​​p>

有很多网站(twitter、facebook..)都应用了这种方法,但是不明白如何在 Grails 中完成它,而不使用例如相同的操作(AppControlle>index)并呈现不同的视图当用户处于活动状态时。

 static mappings = {
    "/"(controller:"app",action:"index")

    "/$controller/$action?/$id?"{
      constraints {
        // apply constraints here
      }
    }

    "500"(view:'/error')
    "404"(view:'/notFound')
  }

【问题讨论】:

    标签: url grails mapping


    【解决方案1】:

    关于您对 twitter、facebook 的提及...我认为他们可能会根据请求使用不同的映射是 POST 还是 GET。在 Grails 中,我们可以像这样进行这种映射:

    name home: "/" {
        controller = [GET: "app", POST: "user"]
        action = [GET: "index", POST: "userIndex"]
    }
    

    【讨论】:

      猜你喜欢
      • 2022-10-23
      • 2011-03-27
      • 2021-01-26
      • 2012-10-17
      • 2017-05-06
      • 2015-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多