In order to send appropriate response, I need to detect whether the controller action has been requested by a classic HTTP GET request, an AJAX request or a g:include tag lib.
For instance, considering the following snippet code:
class CommunityController {
  def show = {
    def users = getUsers()
    if (/* WHAT IS THE CODE HERE??? */)  //g:include request => render 'show' template only
      render template:'show', model=[users]
    else if (request.xhr)  //Ajax => we send JSON content
      render users as JSON
    else //Classic request => we render 'show' G开发者_开发技巧SP page
      [users]
  }
}
...how can I detect that the action has been called via a g:include tag lib?
Thank you.
You can test it like this:
import org.springframework.web.util.WebUtils
if (request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)) {
    // request was included
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论