谁能推荐一个简单的 Java 网络应用程序框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/116978/
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
Can anyone recommend a simple Java web-app framework?
提问by sanity
I'm trying to get started on what I'm hoping will be a relatively quick web application in Java, yet most of the frameworks I've tried (Apache Wicket, Liftweb) require so much set-up, configuration, and trying to wrap my head around Maven while getting the whole thing to play nice with Eclipse, that I spent the whole weekend just trying to get to the point where I write my first line of code!
我正在尝试使用 Java 开发一个相对较快的 Web 应用程序,但我尝试过的大多数框架(Apache Wicket、Liftweb)都需要如此多的设置、配置和尝试把我的头围绕在 Maven 上,同时让整个事情与 Eclipse 一起玩得很好,我整个周末都在努力编写我的第一行代码!
Can anyone recommend a simple Java webapp framework that doesn't involve Maven, hideously complicated directory structures, or countless XML files that must be manually edited?
谁能推荐一个简单的 Java webapp 框架,它不涉及 Maven、极其复杂的目录结构或无数必须手动编辑的 XML 文件?
采纳答案by opensas
Haven't tried it myself, but I think
自己没试过,但我觉得
has a lot of potential...
有很大的潜力...
coming from php and classic asp, it's the first java web framework that sounds promising to me....
来自 php 和经典的 asp,它是第一个对我来说很有希望的 java web 框架......
Edit by original question asker - 2011-06-09
由原始提问者编辑 - 2011-06-09
Just wanted to provide an update.
只是想提供更新。
I went with Play and it was exactly what I asked for. It requires very little configuration, and just works out of the box. It is unusual in that it eschews some common Java best-practices in favor of keeping things as simple as possible.
我选择了 Play,这正是我所要求的。它只需要很少的配置,开箱即用。不寻常的是,它避开了一些常见的 Java 最佳实践,而倾向于使事情尽可能简单。
In particular, it makes heavy use of static methods, and even does some introspection on the names of variables passed to methods, something not supported by the Java reflection API.
特别是,它大量使用静态方法,甚至对传递给方法的变量名称进行了一些内省,这是 Java 反射 API 不支持的。
Play's attitude is that its first goal is being a useful web framework, and sticking to common Java best-practices and idioms is secondary to that. This approach makes sense to me, but Java purists may not like it, and would be better-off with Apache Wicket.
Play 的态度是它的首要目标是成为一个有用的 Web 框架,而坚持通用的 Java 最佳实践和习惯用法是次要的。这种方法对我来说很有意义,但 Java 纯粹主义者可能不喜欢它,并且使用Apache Wicket会更好。
In summary, if you want to build a web-app with convenience and simplicity comparable to a framework like Ruby on Rails, but in Java and with the benefit of Java's tooling (eg. Eclipse), then Play Framework is a great choice.
总而言之,如果您想构建一个与 Ruby on Rails 这样的框架类似的方便和简单的 Web 应用程序,但使用 Java 并利用 Java 的工具(例如 Eclipse),那么 Play Framework 是一个不错的选择。
回答by Aaron Maenpaa
I like writing plain old servlets+winstoneservlet container. From there I bolt on templating (velocity, XSLT, etc) and DB access (hibernate, torque, etc) libraries as I need them rather than going in for an actual framework.
我喜欢编写普通的旧 servlets+ winstoneservlet 容器。从那里,我根据需要使用模板(速度、XSLT 等)和数据库访问(休眠、扭矩等)库,而不是进入实际框架。
回答by GHad
Your're searching for http://grails.org/
您正在搜索http://grails.org/
You code it with groovy, a dynamic language based upon Java and runs smoothly together with Java code, classes and libraries. The syntax is neither hard to learn nor far away from Java. Give it a try, it's some minutes to get a web site up and running. Just follow http://grails.org/Installationand http://grails.org/Quick+Start
您可以使用 groovy(一种基于 Java 的动态语言)对其进行编码,并与 Java 代码、类和库一起顺利运行。语法既不难学,也与 Java 相差甚远。试一试,只需几分钟即可启动并运行网站。只需遵循http://grails.org/Installation和http://grails.org/Quick+Start
Greetz, GHad
格雷茨,GHa
回答by davetron5000
回答by Eduardo Campa?ó
Have you tried DWR? http://directwebremoting.org
你试过DWR吗?http://directwebremoting.org
回答by Kyle
Grails is written for Groovy, not Java. AppFuse merely reduces the setup time required to get any number of Webapp frameworks started, rather than promoting any one of them.
Grails 是为 Groovy 而不是 Java 编写的。AppFuse 只是减少了启动任意数量的 Webapp 框架所需的设置时间,而不是促进其中的任何一个。
I'd suggest Spring MVC. After following the well-written tutorials, you'll have a simple, easy model auto-wired (with no XML configuration!) into any view technology you like.
我建议使用 Spring MVC。遵循精心编写的教程后,您将拥有一个自动连接(无需 XML 配置!)到您喜欢的任何视图技术的简单、简单的模型。
Want to add a "delete" action to your list of customers? Just add a method named "delete" to your customer controller, and it's autowired to the URL /customers/delete.
想要在您的客户列表中添加“删除”操作?只需向您的客户控制器添加一个名为“delete”的方法,它就会自动连接到 URL /customers/delete。
Need to bind your request parameters onto an object? Just add an instance of the target object to your method, and Spring MVC will use reflection to bind your parameters, making writing your logic as easy as if the client passed a strongly-typed object to begin with.
需要将您的请求参数绑定到一个对象上吗?只需将目标对象的一个实例添加到您的方法中,Spring MVC 将使用反射来绑定您的参数,从而使您的逻辑的编写就像客户端首先传递一个强类型对象一样简单。
Sick of all the forced MVC division of labor? Just have your method return void, and write your response directly to the servlet's Writer, if that's your thing.
厌倦了所有强制的 MVC 分工?只需让您的方法返回 void,然后将您的响应直接写入 servlet 的 Writer,如果这是您的事的话。
回答by bpapa
I like Spring MVC, using 2.5 features there is very little XML involved.
我喜欢 Spring MVC,使用 2.5 特性,几乎没有涉及 XML。
回答by killdash10
Check out WaveMaker for building a quick, simple webapp. They have a browser based drag-and-drop designer for Dojo/JavaScript widgets, and the backend is 100% Java.
查看 WaveMaker 以构建快速、简单的 web 应用程序。他们有一个基于浏览器的 Dojo/JavaScript 小部件拖放设计器,后端是 100% Java。
回答by ScArcher2
The Stripes Frameworkis an excellent framework. The only configuration involved is pasting a few lines in your web.xml.
该条纹框架是一个很好的框架。唯一涉及的配置是在 web.xml 中粘贴几行。
It's a very straight forward request based Java web framework.
这是一个非常简单的基于请求的 Java Web 框架。
回答by John Stauffer
I am reallygrooving to Stripes. Total setup includes some cut-and-paste XML into your app's web.xml, and then you're off. No configuration is required, since Stripes is a convention-over-configuration framework. Overriding the default behavior is accomplished via Java 1.5 annotations. Documentation is great. I spent about 1-2 hours reading the tutorial and setting up my first app.
我真的开槽到条纹。总设置包括将一些 XML 剪切和粘贴到您的应用程序的 web.xml 中,然后您就可以关闭了。不需要配置,因为 Stripes 是一个约定优于配置的框架。覆盖默认行为是通过 Java 1.5 注释完成的。文档很棒。我花了大约 1-2 个小时阅读教程并设置我的第一个应用程序。
I can't do an in-depth comparison to Struts or Spring-MVC yet, since I haven't built a full-scale in it yet (as I have in Struts), but it looks like it would scale to that level of architecture quite well.
我还不能对 Struts 或 Spring-MVC 进行深入比较,因为我还没有在其中构建完整的规模(就像我在 Struts 中所做的那样),但看起来它会扩展到那个级别架构相当不错。
回答by anjanb
Stripes : pretty good. a book on this has come out from pragmatic programmers : http://www.pragprog.com/titles/fdstr/stripes. No XML. Requires java 1.5 or later.
条纹:还不错。一本关于这方面的书来自实用的程序员:http: //www.pragprog.com/titles/fdstr/stripes。没有 XML。需要 Java 1.5 或更高版本。
tapestry : have tried an old version 3.x. I'm told that the current version 5.x is in Beta and pretty good.
挂毯:尝试过旧版本 3.x。有人告诉我,当前的 5.x 版本是 Beta 版,非常好。
Stripes should be the better in terms of taking care of maven, no xml and wrapping your head around fast.
条纹在照顾 Maven 方面应该更好,没有 xml 和快速环绕你的头。
BR,
~A
BR,
~A