-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Description
Stephen Medders opened SPR-11827 and commented
The method locateToBeMarshalled in org.springframework.web.servlet.view.xml.MarshallingView checks to see if the object from the model is supported by the marshaller, and throws an exception if it is not:
if (!this.marshaller.supports(obj.getClass())) {
throw new IllegalStateException("Model object [" + obj + "] retrieved via key [" +
this.modelKey + "] is not supported by the Marshaller");
}
In some circumstances, a service may need to marshal an object that requires wrapping in a JAXBElement before marshalling. In this case, the obj variable will be of class JAXBElement. Calls to marshaller.supports(obj) when obj is a JAXBElement always returns false, at least for the Spring Jaxb2Marshaller. An additional check should be added so that if obj is a JAXBElement, then check if the marshaller supports the class of that elements value:
this.marshaller.supports(jaxbElement.getDeclaredType());
Affects: 4.0.5
Referenced from: commits e4aabd5
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement