现有应用程序的 MVC 框架
我正在修改很久以前编写的现有java web应用程序,并且它是以最糟糕的方式编写的。它在 JSP 文件中包含业务逻辑和 sql 语句。
由于某些限制,我无法重新设计整个应用程序。但我可以在我添加的任何新功能中实现更好的设计。
任何人都可以向我推荐任何可以轻松集成到现有应用程序中的 MVC 框架吗?我需要一个不依赖于许多外部 jar 文件的框架,并且它不会对现有应用程序造成任何问题。
I am modifying existing java web application that was written long time ago, and it is written in the wrost possible way. It has business logic and sql statemens in JSP files.
Because of the certain constraint, I can not re-design the entire application. but I can implement better design in any new feature that I add.
can anybody suggest me any MVC framework that I could easily integrate in existing app. I need to have framework that is not depended on many external jar files and it does not cause any issues with existing application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说,听起来像是一个被抛弃的好候选人。
整个应用程序需要重新设计,但你无法重新设计整个应用程序。这是矛盾的。
您不可避免地会导致现有应用程序出现问题,并且如果您使用框架,将会存在外部 JAR 依赖项。我仍然会推荐它,因为框架会给你带来提升,值得额外的 JAR。您的 WAR 文件会更大 - 那又怎样?磁盘空间很便宜。
在我看来,MVC 是最不重要的问题。您应该首先关注正确分层的应用程序的想法。如果您有明确定义的持久性和服务层,您可能会有机会。
现在先考虑一下问题,不要担心 UI。从持久层开始。启动 DAO 和模型对象。然后进入服务层:事务、工作单元以及使用 DAO 和模型对象实现的用例。对两层进行彻底的单元测试。
一旦你有了这些,你就可以集中精力让视图层正常工作。让控制器与服务交互会更容易。您的 UI 可以是 HTML、CSS 和 JavaScript 或 Flex。所有逻辑都将脱离视图并进入其所属的后端。
不要害怕 JAR 依赖性。它可能会引导你远离那些对你有帮助的事情。我首先推荐Spring。它将帮助您解决所有分层问题。它的 Web MVC 也非常出色。
Sounds like a good candidate for being thrown away to me.
The entire app needs to be re-designed, but you can't redesign the entire app. It's contradictory.
You can't help but cause issues with the existing application, and there will be external JAR dependencies if you use a framework. I'd still recommend it, because a framework will give you a lift that will be worth the extra JARs. Your WAR file will be bigger - so what? Disk space is cheap.
Sounds to me like MVC is the least of your problems. You should be concentrating on the idea of a properly layered application first. If you had well-defined persistence and service tiers you might have a chance.
Think about the problem without worrying about the UI for now. Start with the persistence tier. Get a DAO and model objects going. Then move onto the service tier: transactions, units of work, and use cases implemented using the DAO and model objects. Unit test both layers thoroughly.
Once you have those you're free to concentrate on making the view tier work properly. It'll be easier letting the controllers interact with services. Your UI can be HTML, CSS and JavaScript or Flex. All the logic will be out of the view and into the back end where it belongs.
Don't be afraid of JAR dependencies. It could steer you away from something that will help you. I'd recommend Spring first and foremost. It'll help with all your layering issues. Its web MVC is as good as there is, too.
如果你无法重新设计整个应用程序并且担心框架的重量,那么我建议不要添加框架。您最终会得到一个弗兰肯斯坦构建,其中应用程序不一致,并且没有太多好处。
相反,为什么不自己推出呢?当您添加新功能(或修改现有功能)时,您不必将所有内容都塞进 jsp 中。创建您自己的数据访问层和您自己的业务对象,并将它们相互链接并适当链接到 jsps 中的 UI。
If you can't re-design the whole application and are concerned about the weight of the framework, then I suggest not adding a framework. You'll end up with a Frankenstein build where the application is inconsistent, and not a lot of benefit.
Instead, why not roll your own? When you add new features (or revise existing ones), you don't have to cram everything into a jsp. Create your own data access layer, and your own business object, and link those to each other and to the UI in your jsps appropriately.