How can I return a 404/50x status code from a Grails Controller?

前端 未结 4 1695
傲寒
傲寒 2020-12-14 14:11

I have a controller that needs to return a 404 page and status code on certain conditions. I can\'t seem to find out how to do this in Grails. A coworker recommended this me

4条回答
  •  暖寄归人
    2020-12-14 14:30

    response.sendError(404) will work with Grails UrlMappings whereas response.status = 404 does not for some reason. This is useful if you want to render a custom 404 error page, as opposed to just sending 404 back to the browser.

提交回复
热议问题