我有一些通过InputStream加载的文件,如:
InputStream model = new FileInputStream(modelFile);
但是这个过程非常慢,所以我需要在启动时加载它们一次,而不是在出现请求时加载。
我知道在.NET MVC中实现它的一些方法,比如通过Global.asax或CacheHelper,但不知道如何在Spring中完成。
我在上读到,他们使用依赖注入来加载每个mvc请求上的存储库实例。
我不确定我是否正确理解,但我目前使用在我的mvc应用程序。UserRepository实现了IUserRepository接口。此接口被注入控制器构造函数中。
public class UserController : Controller
{
private IUserRepository repository;
public UserController(IUserRepository rep)
{ repository = rep; }
public UserController() : this
我在弄清楚如何使这种存储库模式工作时遇到了一些麻烦。
简而言之,我的解决方案是这样的…
ASP.Net MVC
^
|
Business Logic
^
|
Data Access
(Repositories and Unit of Work)
^
|
Entity Framework Models
我有一个引用Roles表的Users表。
在我的MVC应用程序中,我使用GetAllUser
我目前正在使用MVC控制器中的JQuery标准数据库。
我的模型包含几千条记录,并且在第一次加载期间。加载花费了几秒钟的时间,并且在loading.Datatable期间页面变得非常长,在所有加载之后设置为每页10条记录。
所以我决定使用datatable服务器端mvc,减少第一个加载的time.How,让它在mvc中工作它的实体框架?
public ActionResult ProductList() {
ProductModel model = new ProductModel();
model = db.productModels.ToList();