SPR-6785 - Improve message error when the MarshallingView modelKey attribute is not valid

This commit is contained in:
Arjen Poutsma
2010-02-01 15:25:29 +00:00
parent 1dbb64580c
commit 208c2d9c8b
2 changed files with 26 additions and 0 deletions

View File

@@ -122,6 +122,9 @@ public class MarshallingView extends AbstractView {
protected Object locateToBeMarshalled(Map model) throws ServletException {
if (this.modelKey != null) {
Object o = model.get(this.modelKey);
if (o == null) {
throw new ServletException("Model contains no object with key [" + modelKey + "]");
}
if (!this.marshaller.supports(o.getClass())) {
throw new ServletException("Model object [" + o + "] retrieved via key [" + modelKey +
"] is not supported by the Marshaller");