Spark: ModelAndView Model should be Map<String, Object>

Created on 23 Jul 2016  路  4Comments  路  Source: perwendel/spark

No matter what template engine I look at, they all ways want a Map for the model. I think that the ModelAndView needs to be changed from Object to this to stop all of the unchecked casting and all the checking to make sure that it is a Map in the first place.

Any thoughts?

Most helpful comment

@tipsy Exacly, when you create a ModelandView the actual Model Map within that class should be changed from Object to Map to cure what I said in my first comment.

All 4 comments

Not so. As a matter of fact you are quite able to return a string. Or a stream. In any backend worthy of that name.
Imagine having to return a PDF as a stream in the form of a Map - not going to fly.

But the model and view class is purly for using template engines and nothing else. I don't get where you are coming from with your pdf and stream example?

@ruurd I don't think he means the return value, just that the template-parameters should be map model, string path in stead of object model, string path. As he said, all template engines require a model of type map for rendering templates.

@tipsy Exacly, when you create a ModelandView the actual Model Map within that class should be changed from Object to Map to cure what I said in my first comment.

Was this page helpful?
0 / 5 - 0 ratings