为什么业务逻辑要移出JSP? [英] why business logic should be moved out of JSP?

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

问题描述

将业务逻辑保留在 JSP 之外有什么好处,因为 JSP 主要用于表示?我们仍然看到 JSP 内部编写的业务逻辑,所以我需要知道将业务逻辑移出 JSP 可以获得什么好处.

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.

推荐答案

MVC 是您可以拥有多视图和干净分离的架构&简单

可重用性

假设明天您需要在桌面应用上运行相同的应用.然后你可以改变视图.

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

可测试性

您可以对服务方法进行单元测试,但不能简单地从视图中对逻辑进行单元测试.

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

可维护性

Service 方法中的代码很容易理解,我们也可以更改它/发布服务 api 并轻松维护

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

版本能力

如果您使用服务 API 代替逻辑视图,您可以为 API 提供版本并维护与问题/更新相关的标准文档

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

另见

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆