Code example for WebRequest

Methods: setAttribute

	protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, 
			HttpHeaders headers, HttpStatus status, WebRequest request) { 
		if (HttpStatus.INTERNAL_SERVER_ERROR.equals(status)) { 
			request.setAttribute("javax.servlet.error.exception", ex, WebRequest.SCOPE_REQUEST); 
		return new ResponseEntity<Object>(body, headers, status); 
	 * Customize the response for NoSuchRequestHandlingMethodException. 
	 * This method logs a warning and delegates to 
	 * {@link #handleExceptionInternal(Exception, Object, HttpHeaders, HttpStatus, WebRequest)}. 
	 * @param ex the exception 
	 * @param headers the headers to be written to the response 
	 * @param status the selected response status 
	 * @param request the current request 
	 * @return a {@code ResponseEntity} instance