什么是 ASP.NET / PHP 的主流 Java 替代品
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2556553/
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
What is the main-stream Java alternative to ASP.NET / PHP
提问by Veronika D
I've heard something and seen some examples of web application built using ASP.NET / PHP and I'm wondering what would be the equivalent way of doing similar things in Java world. Looking on the Wikipedia I have found a lot of frameworks and I'm kind of confused which one is the best.
我听说过一些使用 ASP.NET/PHP 构建的 Web 应用程序的例子,我想知道在 Java 世界中做类似事情的等效方法是什么。查看维基百科我发现了很多框架,我有点困惑哪个是最好的。
采纳答案by BalusC
The Java equivalent of PHPand "Classic" ASPwould be JSP (JavaServer Pages)with scriptlets(embedded raw Java code). Scriptletsare considered poor practicein Java web development world. Taglibs and EL (Expression Language) should be preferred above scriptlets. The Java equivalent of ASP.NET(MVC)would be a Java MVC framework. There are a lot of Java-based MVC frameworks out, mostly providing a Servlet/Filter-based controller and taglibs to interact with the model (usually a Javabean) and the view (usually a JSP page, but XHTML is also possible).
PHP和“经典”ASP的 Java 等价物将是带有scriptlet(嵌入原始 Java 代码)的JSP(JavaServer Pages)。在 Java Web 开发世界中,Scriptlet被认为是糟糕的做法。Taglibs 和 EL(表达式语言)应该比scriptlets更受欢迎。ASP.NET (MVC)的 Java 等价物将是 Java MVC 框架。有很多基于 Java 的 MVC 框架,主要提供了一个基于 Servlet/Filter 的控制器和标签库来与模型(通常是Javabean)和视图(通常是 JSP 页面,但 XHTML 也是可能的)进行交互。
To start, the Java EE APIprovides JSF (JavaServer Faces)for this, which in turn comes along with XHTML based templated view technology known as Facelets. Facelets is seen as a replacement of the good old JSP. Further, there are a lot of open source Java MVC frameworks which are built on top of the JSP/Servlet APIand which are intended as an alternative/competitionto JSF. You can find little information of all of them here, the popular ones being Spring MVC, Struts2and Stripes.
首先,Java EE API为此提供了JSF(JavaServer Faces),而JSF(JavaServer Faces)又伴随着基于 XHTML 的模板化视图技术,称为Facelets。Facelets 被视为很好的旧 JSP 的替代品。此外,有许多开源 Java MVC 框架构建在 JSP/ Servlet API之上,旨在作为JSF的替代/竞争。您可以在这里找到所有这些的很少信息,流行的是Spring MVC、Struts2和Stripes。
As to which one to choose, I suggest having a look at this answerwhich I strongly agree.
回答by jsight
The best is not necessarily the same as the most mainstream. I think the most direct equivalent (thanks to its standards track nature) is JSF 2.0 & Facelets.
最好的不一定和最主流的一样。我认为最直接的等价物(由于其标准跟踪性质)是 JSF 2.0 和 Facelets。
Having said that, there are reasons that the other frameworks exist... it's best to evaluate several and determine which one fits your team's style of development best.
话虽如此,其他框架存在是有原因的……最好评估几个并确定哪一个最适合您团队的开发风格。
See also this question.
另请参阅此问题。