Raw Servlet vs. Spring MVC [英] Raw Servlet vs. Spring MVC

查看:82
本文介绍了Raw Servlet vs. Spring MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用原始Java Servlet或使用Spring MVC(或任何其他框架)构建Web应用程序的原因是什么?

What are the reasons you should build your web application with raw Java Servlets or by using Spring MVC (or any other frameworks)?

是否应该例外避免使用Spring MVC,使用Raw Servlets做什么有什么好处?

Are there exceptions when you should avoid Spring MVC, what are the advantages of doing it with Raw Servlets?

推荐答案

如果你正在建立一个非常快速和肮脏的演示你不打算稍后扩展,spring会导致很多额外的配置问题(如果你之前已经完成了,那不是真的,但我总是以这种或那种方式与它斗争),所以这可能是一个是时候考虑使用普通的旧servlet了。一般来说,除了一个超级快速和肮脏的演示之外,使用某种形式的MVC框架将使未来的生活变得更加容易并且也符合最佳实践。 Spring让事情变得非常简单,只需要花一些时间在前端配置所有东西。

If you're building a really quick and dirty demo that you have no intention of extending later, spring can result in a lot of additional configuration issues (not really if you've done it before, but I always end up fighting with it one way or another), so that might be a time to consider just using plain old servlets. Generally though, anything beyond just a super fast and dirty demo, using some form of MVC framework is going to make life in the future a lot easier and is also in line with best practices. Spring makes things super easy, just have to spend some time on the front end configuring everything.

我应该注意,你可以用java servlet做任何事情都没有'与春天一起做。最大的不同是设置时间。

I should note, there's nothing you can do with java servlets that you can't do with Spring. The big difference is setup time.

编辑:值得注意的是,当我发布这个答案时,我不知道Spring Boot实际上是很容易使用嵌入式Web服务器或更传统的Web容器来运行。以下是快速入门示例的链接: http://projects.spring.io/spring -boot /#quick-start

It's worth noting that when I posted this answer, I was unaware of Spring Boot that is actually quite easy to get up an running using either an embedded web server or a more conventional web container. Here's a link to a quick start example: http://projects.spring.io/spring-boot/#quick-start

这篇关于Raw Servlet vs. Spring MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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