Grails “render” renders the template

后端 未结 4 2129
無奈伤痛
無奈伤痛 2021-02-06 01:20

In my Grails controller I\'m responding to an AJAX call and using render to return the text:

def ajaxRandomPersonName = {
    def person = get a ran         


        
4条回答
  •  佛祖请我去吃肉
    2021-02-06 02:05

    You might be getting burnt by the 'layout-by-convention' feature in Grails. If your layout name matches the controller name prefix, for example, Grails will apply the layout to every view managed by that controller. Unfortunately, it even applies to text and templates. There are currently a few JIRAs logged regarding this (see http://jira.grails.org/browse/GRAILS-7624 for example). I got burnt by this today. I resolved it by simply renaming my layout gsp such that it doesn't match any controller name. My layout was initially named 'storefront.gsp' and I have a controller named StorefrontController. I renamed the layout to 'public.gsp'.

提交回复
热议问题