1

我正在使用 MVC 模式开发应用程序。

控制器:servlet

模型:我遵循DAO/DTO 模式来访问数据库

视图:简单的 JSP EL 和 JSTL

为了访问数据库,我使用的是DAO 模式。我想将验证方法和错误消息的 HashMap 放在 DTO 类中以验证 FORM 数据,类似于将验证方法和哈希图放入 DTO

我的问题是 - 这是一个正确的方法吗?如果不是这样做的理想方法是什么?

作为总结:当我们使用 DAO/DTO 模式时,我想知道服务器端表单验证的真实解决方案。请帮我。

4

1 回答 1

0

I believe you need to treat separately the architecture you're implementing and the frameworks you're using to implement the architecture.

Java has a rich set of tools for working on the three standard tiers of your application and choices depend on some factors like expected load and server resources, if you have a two or three users application then it is just a matter of taste.

In terms of DAO/DTO then you have also some options, for example you can build your Data access layer with hibernate and then for your service layer API use DTO's. In this situation you probably want to use a tool for mapping between your domain model and your DTO's (for example jDTO Binder).

Another common approach is to use Spring JDBC Template, there you can go a little bit more crazy and use the same Domain objects as part of the Service layer API.

Finally, the truth is, you can do this by the book or you can do it completely different choice is based on your scenario, taste and experience.

于 2013-06-01T12:09:48.640 回答