Java Web 应用程序前端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28697225/
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 06:39:18  来源:igfitidea点击:

Java web application Front end

javaspringjakarta-eewebstruts

提问by daoud175

I have a large application that is using Java on the backend and struts, Jsp and JSTL tag library on the front end. Database is DB2 and we rely heavily on Stored procedures.

我有一个大型应用程序,它在后端使用 Java,在前端使用 struts、Jsp 和 JSTL 标记库。数据库是 DB2,我们严重依赖存储过程。

We are planning to upgrade the application to a new architecture/framework.

我们计划将应用程序升级到新的架构/框架。

The main framework we are considering is Spring, although our leads are trying to push us to adopt Java EE instead claiming it's better framework.

我们正在考虑的主要框架是 Spring,尽管我们的领导试图推动我们采用 Java EE,而不是声称它是更好的框架。

Any recommendations as to which way to go with Spring or Java EE? Any main reasons to prefer one over the other (advantage/disadvantage)?

关于使用 Spring 或 Java EE 的方式有什么建议吗?有没有偏爱其中一个的主要原因(优势/劣势)?

For each one of those, what is the best alternative for JSP taglib ? We use to have to write all the html tags manually to display dynamic data with JSTL. I am reading about new frameworks like Angular and JSF components. I am not sure also what is widely used these days. I read that more and more programmers are passing the data from REST services as JSON to front-end. What do they use to render the data, is it JSF, Angular?

对于其中的每一个,JSP taglib 的最佳替代品是什么?我们过去必须手动编写所有 html 标签才能使用 JSTL 显示动态数据。我正在阅读有关 Angular 和 JSF 组件等新框架的信息。我也不确定这些天广泛使用的是什么。我读到越来越多的程序员正在将数据从 REST 服务作为 JSON 传递到前端。他们用什么来渲染数据,是 JSF 还是 Angular?

I do .NET programming, and in ASP.NET we have data binding and components like ListView, etc. Are JSF and Angular the same?

我做 .NET 编程,在 ASP.NET 中我们有数据绑定和 ListView 等组件。JSF 和 Angular 是一样的吗?

Any web-site with good examples, documentation (especially architecture) that you recommend?

您推荐的任何具有良好示例、文档(尤其是架构)的网站?

采纳答案by Dogs

Java EE and Spring are both very good and very comprehensive frameworks for writing backends. Both of them should be able to do exactly what you want. I would recommend using whichever your team is familiar with but I'm going to stay out of the details since you will be able to make a high quality application with either one very easily.

Java EE 和 Spring 都是编写后端的非常好的和非常全面的框架。他们都应该能够完全按照您的意愿行事。我建议使用您的团队熟悉的任何一种,但我将不涉及细节,因为您将能够非常轻松地使用其中任何一种来制作高质量的应用程序。

As far as the front-end goes, I have personally gotten the best results out of creating a RESTful API and using that to send data to a front-end Javascript framework. Angular is really good for this. One reason for this is that the Javascript frameworks tend to provide a lot of power when it comes to writing good web front-ends. JSF is a server-side, component based MVC framework, and that generally gives you less control over the the HTML + JavaScript that's being created and makes it a lot more difficult to write tests for.

就前端而言,我个人通过创建 RESTful API 并使用它向前端 Javascript 框架发送数据获得了最好的结果。Angular 对此非常有用。原因之一是 Javascript 框架在编写优秀的 Web 前端时往往会提供很多功能。JSF 是一个服务器端、基于组件的 MVC 框架,这通常使您对正在创建的 HTML + JavaScript 的控制较少,并且使其编写测试变得更加困难。

I've also found that at large shops, you can't always trust people to do things the right away. Separation of concerns is important, and I like using a JavaScript framework like Angular for the front-end because it goes a long way to keep front-end code out of the back-end. The JSF applications we have at my workplace are rather terrible, because the developers abused things like sessions. The JSF code also lived in the same deployment as the backend. Instead of using web services and taking a service oriented approach and keeping everything loosely coupled, we wound up with giant 'blobs' of code that 'do everything'.

我还发现在大型商店中,您不能总是相信人们会立即做事。关注点分离很重要,我喜欢在前端使用像 Angular 这样的 JavaScript 框架,因为它可以让前端代码远离后端。我们在我工作场所的 JSF 应用程序相当糟糕,因为开发人员滥用了诸如会话之类的东西。JSF 代码也与后端位于同一部署中。我们没有使用 Web 服务并采用面向服务的方法并保持一切松散耦合,而是使用了“做所有事情”的巨大“blob”代码。

回答by Joginder Malik

A lot depends upon your team they are comfortable with.Both Spring and Java EE can do everything for you, but personally I will suggest spring jdbc + spring mvc modules for backend. Spring injection functionality is very helpful for web application. Also spring jdbc module create environment and create sessionFactory for your jdbc calls.

很大程度上取决于他们熟悉的团队。Spring 和 Java EE 都可以为您做任何事情,但我个人建议后端使用 spring jdbc + spring mvc 模块。Spring 注入功能对 Web 应用程序非常有帮助。还 spring jdbc 模块创建环境并为您的 jdbc 调用创建 sessionFactory。

Create rest-api in your controller that will make your life very easy. Spring also provides a lot of templates which act as base classes to make using the Java EE standard technologies a breeze to work with. For example, the JdbcTemplate works well with JDBC, the JpaTemplate does good things with JPA, JmsTemplate makes JMS pretty straightforward.

在您的控制器中创建 rest-api,这将使您的生活变得非常轻松。Spring 还提供了许多用作基类的模板,使使用 Java EE 标准技术变得轻而易举。例如,JdbcTemplate 与 JDBC 配合得很好,JpaTemplate 与 JPA 配合得很好,JmsTemplate 使 JMS 变得非常简单。

Also for maintence point of view spring is best because it is popular and mostly developers are familier with spring.

同样从维护的角度来看,spring 是最好的,因为它很受欢迎,而且大多数开发人员都熟悉 spring。

For front end angular is superb because AngularJS has a built-in dependency injection subsystem that helps the developer by making the application easier to develop, understand, and test.

对于前端,angular 非常棒,因为 AngularJS 有一个内置的依赖注入子系统,它通过使应用程序更易于开发、理解和测试来帮助开发人员。

Data-binding is probably the coolest and most useful feature in AngularJS. It will save you from writing a considerable amount of boilerplate code.

数据绑定可能是 AngularJS 中最酷、最有用的特性。它将使您免于编写大量样板代码。