model view controller in grails with out database

2019-07-12 01:19发布

问题:

I don't have any experience with MVC, and am trying to use Grails to write a simple web app. All the examples I've found assume you have a database to base your domain classes off of, and there for have a model based on a database. I'm getting data through an API that does socket communication, and would want the model to be based on that Data. Are there any examples of using a source other then a database for the model component of an MVC app? I'd prefer the examples to be in Grails but will sue any web based examples I can get.

回答1:

Check out command objects. They're pretty much like domain objects as you can do neat things like validation on them, but they're not mapped to any database.