XmlReturnValueHandler class final

ReturnValueHandler implementation that handles XML-serializable controller return values.

This handler activates for controller methods intended to return XML responses and automatically serializes the return value as XML using an appropriate HttpMessageConverter.

Overview

When a handler returns an object with XML media type negotiation, this handler locates an appropriate converter and delegates serialization.

Content-Type header negotiation is applied globally by the DefaultReturnValueHandlerManager before handler invocation, ensuring consistent header management across all handlers.

Responsibilities

  • Determine eligibility for XML serialization
  • Select suitable HttpMessageConverter for the object type
  • Write response using converter with already-negotiated Content-Type
  • Default to 200 OK status when applicable

Error Handling

Throws HttpMediaTypeNotSupportedException if no converter can serialize to the requested type.

Implemented types

Constructors

XmlReturnValueHandler(HttpMessageConverters _converters)
ReturnValueHandler implementation that handles XML-serializable controller return values.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

canHandle(Method? method, Object? returnValue, ServerHttpRequest request) bool
Determines whether this handler can handle the given return value.
override
equalizedProperties() List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
getSupportedMediaTypes() List<MediaType>
Returns the list of media types this handler supports by default.
override
handleReturnValue(Object? returnValue, Method? method, ServerHttpRequest request, ServerHttpResponse response, HandlerMethod? hm) Future<void>
Processes the return value and writes the appropriate response.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited