简体   繁体   English

您能否仅使用 Java 编程语言编写 web 应用程序?

[英]Can you write a web application with just the Java programming language?

My end-of-term assignment is to build a web-based student management application which connects to a MySQL database.我的期末任务是构建一个基于 Web 的学生管理应用程序,该应用程序连接到 MySQL 数据库。 However, the teacher does not allow us to use JS/ node because he says it is not OOP.但是老师不允许我们使用JS/节点,因为他说不是OOP。 Besides from JS, the members in our group can only use Java.除了来自JS,我们群里的成员只能使用Java。

Therefore, I want to ask if it's it possible to do this assignment with just Java.因此,我想问是否可以仅使用 Java 完成此任务。 If it is, what are the things I need to know and learn?如果是,我需要了解和学习哪些内容? Else, is it possible to learn PHP in 1 month for this kind of project?否则,这种项目是否可以在 1 个月内学习 PHP?

Thank you very much for reading!非常感谢您的阅读!

Sure you can write a web app in Java.当然,您可以在 Java 中编写 web 应用程序。 Depending on what you're allowed to use there are tons of options.根据您被允许使用的内容,有很多选项。 Just a short overview, further down means you need more 3rd party code but productivity goes up:只是一个简短的概述,进一步向下意味着您需要更多的 3rd 方代码,但生产力会提高:

  1. Build in on the JDK only.仅在 JDK 上构建。 You'll need to build the WebServer on your own and compose HTML... (Only do this if requirements are strictly forbidding 3rd party libraries)您需要自己构建 WebServer 并编写 HTML...(仅当要求严格禁止第三方库时才这样做)
  2. Use a servlet container like tomcat .使用像tomcat这样的 servlet 容器。 You'll still have to build HTML on your own but request handling is mostly done for you.您仍然需要自己构建 HTML,但请求处理主要是为您完成的。 (Use this if a servlet container is all you're allowed to use) (如果您只允许使用 servlet 容器,请使用此选项)
  3. Use a templating engine like JSP, Thymeleafe, Velocity.使用模板引擎,例如 JSP、Thymelefe、Velocity。 You will be able to build web pages quite easily.您将能够非常轻松地构建 web 页面。 (This would already work conveniently, yet there are still better options) (这已经很方便了,但还有更好的选择)
  4. Use an web application framework.使用 web 应用程序框架。 This will take most boilerplate from you and allow you to use advanced concepts with little effort.这将从您那里获取大部分样板文件,并允许您轻松使用高级概念。 There are multiple frameworks to choose from.有多种框架可供选择。 I prefer Spring Boot and would recommend to start with s.th.我更喜欢Spring Boot并建议从 s.th 开始。 like this (This will automatically provide much of what is asked from you, so check if you can use such a framework).这样(这将自动提供您所要求的大部分内容,因此请检查您是否可以使用这样的框架)。

Yes it is possible to write a webserver in Java without any external (ie not Java SE) libraries.是的,可以在没有任何外部(即不是 Java SE)库的情况下在 Java 中编写网络服务器。 All you need to do is:您需要做的就是:

  • Learn about Socket and ServerSocket and the SSL stack, and...了解SocketServerSocket以及 SSL 堆栈,以及...
  • Spend a few days reading the HTTP specification in sufficient detail to understand what the protocol requires.花几天时间详细阅读 HTTP 规范,以了解协议的要求。
  • Spend a few more days implementing a server-side HTTP protocol stack and so on.再花几天时间实现一个服务器端 HTTP 协议栈等等。

Which is... a lot of effort, and probably a waste of you / your team's time.这是......很多努力,可能会浪费您/您的团队的时间。

If you are going to implement this in Java, you would be much better off either learning Spring / SpringMVC / SpringBoot, or learning Servlets and/or JSPs.如果你打算在 Java 中实现这个,你最好学习 Spring / SpringMVC / SpringBoot,或者学习 Servlets 和/或 JSP。 They deal with the protocol side for you, and (more or less) leave you to focus on the aspects that are specific to your webapp.它们为您处理协议方面,并且(或多或少)让您专注于特定于您的 web 应用程序的方面。

These technologies (or equivalents) are what you are likely to use when you graduate.这些技术(或同等技术)是您毕业时可能使用的技术。

If the other members of your team already know Java, that would be an obvious good reason to use it.如果您团队的其他成员已经知道 Java,那显然是使用它的好理由。

In short, there are 3 reasons to use Java + the above technologies:总之,使用Java+以上技术有3个理由:

  • Less effort更少的努力
  • Less learning for your other team members 1减少其他团队成员的学习1
  • You / they will be learning more immediately useful things.您/他们将学习更多立即有用的东西。

PHP would be another alternative, though if your teachers are "down" on Javascript for being "not OO enough", they are probably unlikely to think well of PHP either. PHP 将是另一种选择,但如果你的老师因为“不够 OO”而对 Javascript “失望”,他们可能也不太可能对 PHP 有好感。

On the topic of whether Javascript is OO or not, read this:关于 Javascript 是否为 OO 的话题,请阅读以下内容:

Read it and make up your own mind.阅读并下定决心。


1 - How about volunteering to write all of the project's documentation so that you don't have to learn Java. 1 - 自愿编写所有项目的文档怎么样,这样您就不必学习 Java。 No?不? You want to learn Java, don't you!学Java,对不对!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JVM语言是由Java Memory Model还是Java Programming Language绑定的? - Are JVM languages bound by the Java Memory Model or just the Java Programming Language? 在Java中更改Web应用程序的语言 - Changing the language of the web application in java 连接池是否根据编程语言或 Web/应用程序服务器工作? - Do the connection pools work according to the programming language or the web/application server? 您可以在 Java EE Web 应用程序中实现 Vue.js 吗? - Can you implement Vue.js in a Java EE web application? 您可以为Java Web应用程序编码推荐一个标准,凉爽的环境吗? - Can you recommend a standard, cool environment for Java web application coding? 您如何用Java编写程序来编译.asm(汇编语言)文件? - How can you write a program in Java to compile .asm (Assembly language) files? 为网络编程时是否应该切换到Java以外的语言? - Should I switch to a language other than Java when programming for web? 以中文显示整个JAVA Web应用程序 - Displaying entire JAVA Web application in Chinese language 关于Java编程语言 - regarding java programming language 我们如何使用Java中的Selenium Webdriver测试不同语言(非英语)的Web应用程序 - How can we test a web application in different language(not english) using selenium webdriver in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM