我应该如何开始基于 Java 的 Web 开发?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1084591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:24:20  来源:igfitidea点击:

How should I start Java-based web development?

javaweb-applications

提问by

I have been using java as my main language for 3 years while developing college assignments, and now I plan to learn the web programming aspect of it. I see there are lots of different "stuff" going on such as JSP, JSF, Spring, etc.

我在开发大学作业时一直使用 java 作为我的主要语言 3 年,现在我计划学习它的 web 编程方面。我看到有很多不同的“东西”在进行,比如 JSP、JSF、Spring 等。

Previous topics suggest that Head First Servlets and JSPis a good book to start with, but what do you think about that? After that, what route I should be following in order, at least to be able to write my own blog site app from scratch?

前面的主题表明Head First Servlets 和 JSP是一本很好的入门书,但您对此有何看法?在那之后,我应该遵循什么路线,至少可以从头开始编写自己的博客站点应用程序?

回答by karim79

I would say:

我会说:

  1. Install Java.
  2. Install Tomcat.
  3. Build a servlet, make it do stuff. Play with Requests and Responses. Get to grips with GET and POST requests, the HTTP protocol, why many web applications need RDBMSs, etc.
  4. If you get stuck on anything, use google, or this site to figure it out.
  5. Get your hands dirty!
  6. Get your hands dirty!
  1. 安装 Java。
  2. 安装Tomcat
  3. 构建一个 servlet,让它做一些事情。玩转请求和响应。掌握 GET 和 POST 请求、HTTP 协议、为什么许多 Web 应用程序需要 RDBMS 等。
  4. 如果您遇到任何问题,请使用谷歌或本网站来解决。
  5. 弄脏你的手!
  6. 弄脏你的手!

回答by Alberto Zaccagni

Just start with your project with the book of your choice by your side. Lots of resources about good books can be found here on stackoverflow.

只需从您身边选择的书开始您的项目。在 stackoverflow 上可以找到很多关于好书的资源。

My advice is to start with making a page to communicate with the server, at least post some data and act depending on the response. At the beginning stick with base scriplets, don't go straight to jsf tag libraries (or whatever else of that kind), understand what is a session, a request, a response and so on.

我的建议是首先创建一个页面与服务器进行通信,至少发布一些数据并根据响应采取行动。一开始坚持使用基本脚本,不要直接进入 jsf 标记库(或任何其他类型的库),了解什么是会话、请求、响应等。

回答by Itay Maman

Use the first few lessons from the Spring step-by-step tutorial: http://static.springsource.org/docs/Spring-MVC-step-by-step/

使用 Spring 分步教程中的前几节课:http: //static.springsource.org/docs/Spring-MVC-step-by-step/

Although the latter lessons are cover advanced Spring functionality the first couple of lessons are about setting up a simple, Tomcat-based web-app.

虽然后面的课程涵盖了高级 Spring 功能,但前几课是关于设置一个简单的、基于 Tomcat 的 web 应用程序。

回答by rajesh pillai

Check JavaPassion.com

查看 JavaPassion.com

It has an online course for java and other related technologies like ajax, jruby, webservices etc. And the coverage is pretty decent.

它有一个关于 java 和其他相关技术(如 ajax、jruby、webservices 等)的在线课程。覆盖面相当不错。

Hope this will be beneficial to you.

希望这对您有益。

回答by Mercer Traieste

First it's important to understand the web languages, html, css, javascript. A good resource would be http://www.alistapart.com/

首先,了解网络语言、html、css、javascript 很重要。一个很好的资源是http://www.alistapart.com/

Then understand how http works, and how servlets are modeling http requests/response cycles. This is a good book: Head First Servlets and JSP.

然后了解 http 的工作原理,以及 servlet 如何建模 http 请求/响应周期。这是一本好书:Head First Servlets and JSP。

Then try out the first java web framework that captures your attention. A good one is Spring Framework.

然后尝试第一个吸引您注意力的 Java Web 框架。一个好的是 Spring 框架。

Good luck!

祝你好运!

回答by Thorbj?rn Ravn Andersen

Be a bit careful. Most solutions to doing web development have a tendency to be very large and hard to get around and learn.

小心一点。大多数进行 Web 开发的解决方案都倾向于非常庞大且难以学习。

I would suggest getting the basics right since you WILL eventually need to know them. The Head First series are well written and a good start.

我建议正确掌握基础知识,因为您最终将需要了解它们。Head First 系列写得很好,是一个良好的开端。

This will teach you JSP's and servlets which is what most of the frameworks build on top of.

这将教您 JSP 和 servlet,这是大多数框架构建的基础。

回答by Sumit Kishore

I kinda had a similar route, although not because I was in college, but because my career of many years involved standalone application development using Java, with no web component involved. Java-based web development basically seemed to pass me by, and I didn't find it easy when I tried to move into the mainstream.

我有点类似的路线,虽然不是因为我在大学,而是因为我多年的职业生涯涉及使用 Java 的独立应用程序开发,不涉及 Web 组件。基于 Java 的 Web 开发基本上似乎被我忽略了,当我试图进入主流时,我发现这并不容易。

Recognize first that web-based development is a pretty large field. From an employment point of view, opportunities tend to drift towards one or other subsections of the field in general. Roughly speaking, front-end and back-end development tend to be viewed as specific enough skills that you might be expected to have expertise in one versus the other, more so now that JavaScript is more central to frontend development.

首先要认识到基于 Web 的开发是一个相当大的领域。从就业的角度来看,机会通常会倾向于该领域的一个或其他部分。粗略地说,前端和后端开发往往被视为足够具体的技能,您可能需要在其中一项与另一项方面拥有专业知识,现在 JavaScript 对前端开发更加重要,因此更是如此。

And the surfeit of frameworks in Java makes it difficult for the newcomer to choose what to begin out with. There's just way too many JavaScript libraries, Web frameworks and application servers or frameworks. Even though your background is in Java, I'd still suggest you try out Rails or maybe Grails to get a better idea of the entire stack, as they have a more coherent story. In Java, there's dominant libraries for sure, but you'll still find your efforts to master them interrupted by constant comparisons to other competing frameworks or so. Or GWT and Wicket, being more based on the Java development style, may mean an easier transition to web technologies. Spring framework is also a good starting point as it has a more or less consistent story from the back- to the front-end, although it is still overwhelming.

Java 中框架的过多使得新手很难选择从什么开始。JavaScript 库、Web 框架和应用程序服务器或框架太多了。即使您的背景是 Java,我仍然建议您尝试使用 Rails 或 Grails 来更好地了解整个堆栈,因为它们有更连贯的故事。在 Java 中,肯定有占主导地位的库,但您仍然会发现您掌握它们的努力会因与其他竞争框架的不断比较而中断。或者更多基于 Java 开发风格的 GWT 和 Wicket,可能意味着更容易过渡到 Web 技术。Spring 框架也是一个很好的起点,因为它从后端到前端都有一个或多或少一致的故事,尽管它仍然是压倒性的。

回答by hrzafer

I had the same question and read this thread and started with Head First. Have read 5 chapters but then I started to search for new resources and found Core Servlets and JavaServer Pages (JSP) from http://pdf.coreservlets.com/and I think this book is much better in many ways.

我有同样的问题并阅读了这个线程并从 Head First 开始。已经阅读了 5 章,但后来我开始搜索新资源,并从http://pdf.coreservlets.com/找到了 Core Servlets 和 JavaServer Pages (JSP) ,我认为这本书在很多方面都要好得多。

  • First of all it is not objected to an exam.
  • Includes much more example with codes.
  • There is many ways to implement a web application in Java. You can use just Servlets, just JSPs or combinations with/without beans etc. This book explains advantages and disadvantages of each very well.
  • Explains MVC from scratch much better. (chapter 15)
  • And it is free.
  • 首先它不反对考试。
  • 包括更多带有代码的示例。
  • 有很多方法可以在 Java 中实现 Web 应用程序。你可以只使用 Servlets,只使用 JSPs 或有/没有 bean 的组合等等。这本书很好地解释了每个的优点和缺点。
  • 从头开始更好地解释 MVC。(第15章)
  • 而且它是免费的。

Update after almost seven years:I highly recommend to take a look at Spark Framework.

近七年后更新:我强烈建议您查看Spark Framework