使用 Java 框架或简单 JSP
是否有必要使用框架而不是普通的OOP语言?我的意思是,如果我想在网络上创建一个时间表,管理员可以将数据添加到表单中并将它们保存在数据库中,然后生成宁静的网络服务。我需要使用 Spring、Struts 等框架创建管理部分吗?或者我可以用简单的 JSP 创建它吗?
is it necessary to use framework rather than normal OOP language? I mean if I want to create a timetable on the web which admin can add data in to form and save them in DB, then produce restful web service. Do I need to create the admin part with frameworks like Spring, Struts? or can I just create it with simple JSP ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
框架用于减少开发时间和工作量。您可以使用简单的 JSP 很好地开发管理模块。但请记住,如果 JSP 中包含过多的 Java 代码,那么 JSP 的可维护性就会降低。
使用框架的缺点是它们会增加二进制文件的大小(战争),并且启动速度可能会更慢(以毫秒为单位),并且开发人员(以及维护应用程序的人员)需要很少的学习曲线)。
如果您的应用程序的管理部分不超过 3-4 页,那么在集成框架和解决其依赖关系以及其他因素上花费的时间可能会超过其实用性。
Frameworks are used to reduce development time and effort. You can very well develop the Admin module with plain JSPs. However bear in mind, that JSPs is less maintainable if too much of java code creeps into them.
The downside of using frameworks is they will increase the size of binary (war), and may be slower start up (in milliseconds), and need little learning curve for developer (and the one who maintains the app).
If your app'a admin part is not exceeding 3-4 pages, time spent in integrating frameworks and resolving their dependencies and other factors may outweigh their utility.
为什么需要框架或者除了 OOP 范式之外使用框架的意义是什么?创建后端面板或管理面板取决于您是否使用 Liferay 或 xWiki Framework。但是,使用 Spring MVC、Struts 1 或 2、JSF 2、EJB 3、Hibernate ORM 或 TopLink 等框架可以在某种意义上简化消息服务、面向事务的实现等的复杂架构情况。这些框架不愿意提供内置管理面板,但像 Liferay 或任何其他 CMS 应用程序可以做到这一点。更具体地说,这些应用程序是使用 Spring MVC 或更具体的类似库或框架构建的。我们需要一个稍微复杂的架构来将业务逻辑与持久层分开,并且服务层应该与其他层分开。我们需要在每一层或组件之间进行松散耦合的结合。因此,您是否遵循任何更具体的架构或只是一个简单的架构取决于您
. If you use Spring MVC there is concept like Acegi Security so if you need security then you can go for Spring MVC. There are many other features for Spring MVC or other frameworks as well.
Why you need Framework(s) or what is the significance of using Frameworks apart from the OOP paradigm? Creating Back-end panel or Admin Panel is upto you whether you use like Liferay or xWiki Framework. But using these kinds of frameworks like Spring MVC, Struts 1 or 2, JSF 2, EJB 3, Hibernate ORM or TopLink would simplify your complex architectural situation in a sense for Messaging Service, for Transaction oriented implementation and lot more. These frameworks are not willing to provide built-in Admin Panel but like Liferay or any other CMS Application can do that. Those Applications are built by using Spring MVC or similar libraries or framework to be more specific. We need a little bit complex architecture to separate Business Logic from Persistence Layer and Service layer should be separated from others. And we need to make loosely coupled bonding between each layer or component. So it is up-to you whether you are following any Architecture to be more specific or just a simple
. If you use Spring MVC there is concept like Acegi Security so if you need security then you can go for Spring MVC. There are many other features for Spring MVC or other frameworks as well.
如果您已经使用这些技术构建了应用程序的一部分,那么您可以继续使用它们来构建应用程序的管理部分。毕竟,它只是应用程序的另一部分。
If you have already built part of your app with those technologies, it stands to reason that you can continue using them to build the admin part of your app. After all, its just another part of the app.
很多框架都会抽象你的视图技术。例如,您可以将 Spring 与 JSP、JSF、Google 的 GWT、Flex 等一起使用。Grails 使用我很喜欢的 SiteMesh。我相信玩!使用直接的 Groovy 文件,或者至少直到最近的版本都是如此。
Tiles2 也非常易于使用,并为您提供了一些基本的“管理部件”功能,因此您不会最终陷入包含兔子洞。
这是一个很棒的教程,它演示了使用 Tiles2 的简单 Spring MVC Web 应用程序来帮助管理 JSP。这也将使您感受到 Spring 中的视图解析器。
http://www.springbyexample.org/examples/simple-tiles -spring-mvc-webapp.html
A lot of the frameworks will abstract your view technology. For example, you can use Spring with JSPs, JSF, GWT from Google, Flex, etc. Grails uses SiteMesh which I've come to enjoy. I believe Play! uses straight-up Groovy files, or at least did until recent releases.
Tiles2 is also pretty easy to use, and gives you some of the basic "manage the parts" functionality so you don't wind up going down the include rabbit hole.
Here is a great tutorial that walks through a simple Spring MVC webapp with Tiles2 to help manage the JSPs. This will also give you a feel for view resolvers within Spring.
http://www.springbyexample.org/examples/simple-tiles-spring-mvc-webapp.html
如果我是你,我会同时做这两件事。我将仅使用 JSP 创建应用程序。那是一个版本。
然后是另一个带有框架的。然后根据您的经验,您就会知道有什么区别。你的应用范围很小,所以你应该两者都尝试一下。
If I were you I will do both. I will create the application with only JSP. That's one version.
Then another one with framework(s). Then from your experience, you will know what are the difference. Your application scope is quite small, so you should try both.
如果您可以 100% 肯定地说您的“一个 JSP”应用程序将永远被扩展,那么好吧,框架的开销可能不值得。但这永远不会发生。您或其他人将请求新功能,您会发现自己希望自己一开始就设置正确。
If you can say with 100% certainty that your "one JSP" app will never be extended, then ok, the overhead of a framework may not be worth it. But that never happens. New features will be requested, by you or someone else, and you will find yourself wishing you had set things up correctly in the first place.