Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## grails.util
[Java] Class GrailsWebUtil

    java.lang.Object
      grails.util.GrailsWebUtil

    public class GrailsWebUtil

Utility methods for clients using the web framework.

Authors:
  Graeme Rocher

Since:
  0.4

Field Summary
`static java.lang.String` | `DEFAULT_ENCODING`

Method Summary
`static GrailsWebRequest` | `bindMockWebRequest(WebApplicationContext ctx)` Binds a Mock implementation of a GrailsWebRequest object to the current thread.
`static GrailsWebRequest` | `bindMockWebRequest()` Binds a Mock implementation of a GrailsWebRequest object to the current thread.
`static java.lang.String` | `getContentType(java.lang.String name, java.lang.String encoding)`
`static groovy.lang.GroovyObject` | `getControllerFromRequest(HttpServletRequest request)` Obtains the currently executing controller from the given request if any.
`static java.lang.String` | `getUriFromRequest(HttpServletRequest request)` Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method.

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### DEFAULT_ENCODING

    public static final java.lang.String DEFAULT_ENCODING

Method Detail

### bindMockWebRequest

    public static GrailsWebRequest bindMockWebRequest(WebApplicationContext ctx)

  Binds a Mock implementation of a GrailsWebRequest object to the current thread. The mock version uses instances of the Spring MockHttpServletRequest, MockHttpServletResponse and MockServletContext classes.
  Parameters:
    `ctx` - The WebApplicationContext to use
  Returns:
    The GrailsWebRequest instance
  See Also:
    org.springframework.mock.web.MockHttpServletRequest
    org.springframework.mock.web.MockHttpServletResponse
    org.springframework.mock.web.MockServletContext

### bindMockWebRequest

    public static GrailsWebRequest bindMockWebRequest()

  Binds a Mock implementation of a GrailsWebRequest object to the current thread. The mock version uses instances of the Spring MockHttpServletRequest, MockHttpServletResponse and MockServletContext classes.
  Returns:
    The GrailsWebRequest instance
  See Also:
    org.springframework.mock.web.MockHttpServletRequest
    org.springframework.mock.web.MockHttpServletResponse
    org.springframework.mock.web.MockServletContext

### getContentType

    public static java.lang.String getContentType(java.lang.String name, java.lang.String encoding)

### getControllerFromRequest

    public static groovy.lang.GroovyObject getControllerFromRequest(HttpServletRequest request)

  Obtains the currently executing controller from the given request if any.
  Parameters:
    `request` - The request object
  Returns:
    The controller or null

### getUriFromRequest

    public static java.lang.String getUriFromRequest(HttpServletRequest request)

  Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method.
  Parameters:
    `request` - The HttpServletRequest instance
  Returns:
    The String URI

Groovy Documentation