现有应用程序的 MVC 框架

发布于 2024-09-04 15:39:09 字数 215 浏览 5 评论 0原文

我正在修改很久以前编写的现有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

二智少女 2024-09-11 15:39:09

我正在修改现有的java web
写了很长时间的应用程序
以前,它是用最坏的方式写的
可能的方式。它有业务逻辑
和 JSP 文件中的 sql 语句。

对我来说,听起来像是一个被抛弃的好候选人。

由于某些限制,我
无法重新设计整个
应用。但我可以实施
任何新功能的更好设计
我补充一下。

整个应用程序需要重新设计,但你无法重新设计整个应用程序。这是矛盾的。

任何人都可以向我推荐任何 MVC
我可以轻松地构建框架
集成到现有的应用程序中。我需要
有不依赖的框架
许多外部 jar 文件,它确实
不会对现有的造成任何问题
应用程序。

您不可避免地会导致现有应用程序出现问题,并且如果您使用框架,将会存在外部 JAR 依赖项。我仍然会推荐它,因为框架会给你带来提升,值得额外的 JAR。您的 WAR 文件会更大 - 那又怎样?磁盘空间很便宜。

在我看来,MVC 是最不重要的问题。您应该首先关注正确分层的应用程序的想法。如果您有明确定义的持久性和服务层,您可能会有机会。

现在先考虑一下问题,不要担心 UI。从持久层开始。启动 DAO 和模型对象。然后进入服务层:事务、工作单元以及使用 DAO 和模型对象实现的用例。对两层进行彻底的单元测试。

一旦你有了这些,你就可以集中精力让视图层正常工作。让控制器与服务交互会更容易。您的 UI 可以是 HTML、CSS 和 JavaScript 或 Flex。所有逻辑都将脱离视图并进入其所属的后端。

不要害怕 JAR 依赖性。它可能会引导你远离那些对你有帮助的事情。我首先推荐Spring。它将帮助您解决所有分层问题。它的 Web MVC 也非常出色。

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.

Sounds like a good candidate for being thrown away to me.

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.

The entire app needs to be re-designed, but you can't redesign the entire app. It's contradictory.

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.

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.

夜无邪 2024-09-11 15:39:09

如果你无法重新设计整个应用程序并且担心框架的重量,那么我建议不要添加框架。您最终会得到一个弗兰肯斯坦构建,其中应用程序不一致,并且没有太多好处。

相反,为什么不自己推出呢?当您添加新功能(或修改现有功能)时,您不必将所有内容都塞进 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文