link directly to GSP

前端 未结 3 1078
青春惊慌失措
青春惊慌失措 2021-02-05 16:47

In a GSP, is it possible to create a direct link to another GSP? I know I can use:


and

3条回答
  •  渐次进展
    2021-02-05 17:21

    The createLink tag is geared for use with controller actions and won't do what you want it to outside of the url attribute.

    You can always get to a gsp by directly: /user/foo.gsp with a combination of the link and resource tags.

    user/foo.gsp
    

    Othewise you can create a URL Mapping that maps a request directly to a view.

    class UrlMappings {
        static mappings = {
            "/user/foo"(view:"user/foo")
        }
    }
    

    Using Grails 1.2 you can create a named URL Mapping that maps directly to a view:

    class UrlMappings {
        static mappings = {
            name userFoo: "/user/foo"(view:"user/foo")
        }
    }
    

    and then use it with the link tag:

    User Foo
    

    or

    User Foo
    

提交回复
热议问题