本文介绍了为什么业务逻辑应该移出JSP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保持JSP以外的业务逻辑有哪些优势,因为JSP主要用于演示?我们仍然看到JSP中写的业务逻辑,所以我需要知道通过将业务逻辑移出JSP来获得什么好处。

解决方案

p> ,你可以拥有多个视图,清洁和分离的架构和






可用性



假设明天你需要一个运行在桌面应用那么你可以更改视图。






可测试性



您可以对您的服务方法进行单元测试,但您不能简单地从单元测试逻辑。






可维护性



很容易从服务方法中了解代码,我们也可以更改/释放服务api并轻松维护






版本能力



你可以给你的API版本,并维护与问题/更新相关的标准文档,如果你使用服务API,而不是查看逻辑






另请参阅








What are the advantages of keeping the business logic outside JSP, since JSP's are meant mainly for presentation? We still see business logic written inside the JSP, so I needed to know what benefit we get by moving business logic out of JSP.

解决方案

The main benefit of MVC is you can have multiple view and clean and separated architecture & Simplicity


Re usability

Suppose tomorrow you need same app running on a desktop app. then you can just change the view.


Testability

You can unit test your service methods, but you can't simply unit test logic from view.


Maintainability

It is easy to understand the code from Service methods, also we can change it /release service api and maintain it easily


Version ability

You can give version to your API and maintain standard docs related to issues/updates if you use service API instead view for logic


See Also

这篇关于为什么业务逻辑应该移出JSP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 08:51
查看更多