最受欢迎的Java Web框架

随着Java多年来的发展,已经进行了多种尝试来简化各种用例的开发。 从像Java Enterprise Edition这样的官方标准到社区驱动的框架,Java一直在证明自己具有适应性和可行性。

Our top list is based on usage from Hotframework.com's Java ranking and several other sources including blog posts and GitHub download numbers.

前三名是:

其他著名的Java Web框架:

流行但不适用于Web的Java框架(我们不想忘记它们):

Spring

Project Site: https://spring.io/

Primary Sponsor: Pivotal Software

Spring is more than just a web framework. It is a complete programming model that is built on and with Java, starting with Spring Boot, which is a way to get a spring application up and running with minimal configuration and no application server required. At the other end of the spectrum is Spring Cloud, which is a combination of components that allows developers to build resilient and reliable cloud-native applications that leverage the latest distributed patterns like a microservices architecture — two examples include application security and batch processing.

Spring有很多用例,并且随着Spring Boot的引入,它对于那些正朝着容器发展的公司提供了很好的解决方案,因为它大大简化了支持运行中的应用程序所需的组件。

Getting started with Spring is as simple as going to Spring Initializr and selecting the build framework you desire and any and all the Spring projects you want included in the initial application. It will create the Maven or Gradle configuration and all the basic spring configuration required to start.

从Initializr开始创建一个简单的Web应用程序(图1):

Spring Initializr

…这将创建一个包含以下文件的Zip文件:

./mvnw.cmd
./pom.xml
./.gitignore
./.mvn/wrapper/maven-wrapper.properties
./.mvn/wrapper/maven-wrapper.jar
./mvnw
./src/test/java/com/example/demo/DemoApplicationTests.java
./src/main/resources/application.properties
./src/main/java/com/example/demo/DemoApplication.java

您需要一个控制器-src / main / java / com / example / demo / DemoController.java:

package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class DemoController {

    @RequestMapping("/hello")
    public String hello() {
        return "hello";
    }

}

还有一个模板文件src / main / resources / templates / hello.html

<!DOCTYPE HTML>
<html>
<head>
    <title>Hello World</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <p>Hello World</p>
</body>
</html>

JSF (Java Server Faces)

Project Site: http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html

Primary Sponsor: Oracle (soon to be a separate foundation)

JSF is a specification for displaying web user interfaces that is defined as part of the Java Platform, Enterprise Edition (JEE). JSF 1 was released in 2004, incorporated into JEE 5 and uses Java Server Pages (.jsp) as its templates. JSF 2 was released in 2009 as part of JEE 6, and leverages Facelets for templating and supports AJAX calls with a browser to allow modern web application lifecycles. JSF is component-based, allowing it to be expanded with additional components. IceFaces and MyFaces are examples of popular add-on components.

由于JSF是Java标准的一部分,因此在希望坚持发布的标准以提高跨平台可移植性的开发团队中很受欢迎。 JSF还允许通过Web界面扩展现有的后端Java代码,而不必通过引入新框架来重构基本应用程序。

一个简单的JSF应用程序需要一个Managed Bean,Facelet并映射Servlet。

helloworld.java

package helloworld;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HelloWorld {

    final String world = "Hello World!";

    public String getworld() {
        return world;
    }
}

helloworld.xhtml

<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelets Hello World</title>
    </h:head>
    <h:body>
        #{hello.world}
    </h:body>
</html>

web.xml

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

GWT (Google Web Toolkit)

Project Site: http://www.gwtproject.org/

主要赞助商:Google

GWT is much like JSF in that it is strictly focused on building web interfaces. It is more popular than native JSF as it makes it easy to maintain complex JavaScript user interfaces with Java code. GWT has lost some of its popularity over the last couple of years as more development teams are pushing Java to the backend and having it expose REST APIs which are consumed by both native mobile apps and user interfaces built in Node.js, using frameworks like Angular.

A tutorial on how to build a simple GWT application can be found on its project site: Getting Started building a GWT app.

Conclusion

总之,有许多可行的Java Web框架可用于满足您的需求。 前三名都不是错误的选择-这取决于个人喜好。 请注意,一旦您提交了一个框架并开始利用其功能,切换到另一个框架并不是一件微不足道的工作。

Øriginally published on rollbar.com

from: https://dev.to//mostlyjason/most-popular-java-web-frameworks-gm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值