[英]Can anyone recommend a Java web framework that is based on MVC and supports REST?
We are looking to host a Java Domain Model (written using DDD) inside a web application. 我们希望在Web应用程序中托管Java域模型(使用DDD编写)。 Ideally I would like to support RESTful resources and requests, having a single site to support both users and a REST api. 理想情况下,我想支持RESTful资源和请求,只有一个站点支持用户和REST API。
Ideally the same url could be used for both end users and the RESTful API of a given feature (with HTTP content types / negotiation specifying the difference). 理想情况下,相同的URL可以用于最终用户和给定功能的RESTful API(HTTP内容类型/协商指定差异)。
I have done similar apps in Ruby on Rails and Asp.mvc, but have no experience doing anything like this in Java. 我在Ruby on Rails和Asp.mvc中做过类似的应用程序,但没有经验在Java中做过这样的事情。 Anybody have an experience or advice on where to start ? 任何人都有从哪里开始的经验或建议? (Googling suggests that Spring v3 might be an answer, anybody have any thoughts on Spring 3 ?) (谷歌搜索表明Spring v3可能是一个答案,任何人都对Spring 3有任何想法?)
Restlets Framework http://www.restlet.org/ Restlets框架 http://www.restlet.org/
I've used this framework extensively, easy to use, really flexible and supports loads of features and more you'd expect from file upload to gzipping responses. 我已经广泛使用了这个框架,易于使用,非常灵活,并且支持大量功能,并且您希望从文件上传到gzipping响应更多。
This module has Spring support too, really easy. 这个模块也有Spring支持,非常简单。 For example: 例如:
web.xml web.xml中
<servlet>
<servlet-name>webapi</servlet-name>
<servlet-class>
com.noelios.restlet.ext.spring.RestletFrameworkServlet
</servlet-class>
</servlet>
spring context 春天的背景
<bean id="root" class="org.restlet.ext.spring.SpringRouter">
<property name="attachments">
<map>
<entry key="/{variable}/your/restful/call/{variable2}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource" bean="yourBean" />
</bean>
</entry>
</map>
</bean>
Framework also has a great documentation , first steps for newbies and a great WIKI . 框架还有一个很好的文档 , 新手的第一步和伟大的WIKI 。
This framework is very mature and actively improved, checkout the up and coming features . 这个框架非常成熟并且积极改进,检查了即将到来的功能 。
It's also very easy to unit test your Restlet Resource endpoints using jmock. 使用jmock对您的Restlet资源端点进行单元测试也非常容易。
Hope that helps. 希望有所帮助。
Spring 3 is not quite ready yet, but the current milestone build (M3) is stable enough to use for real. Spring 3尚未准备就绪,但目前的里程碑版本(M3)足够稳定,可用于真实版本。 We're using its REST support in a production application already. 我们已经在生产应用程序中使用其REST支持。 It's pretty goodm, and integrates very nicely with Spring MVC. 它非常好,并且与Spring MVC很好地集成。 It's not JAX-RS compliant, but I don't see that as a problem. 它不符合JAX-RS,但我不认为这是一个问题。
For web services, Jersey is nice and easy. 对于Web服务, Jersey非常简单。 Spring 3 sounds like it will be good, but it's not out yet, and Jersey is full featured and supports SOAP and JSON out of the box. Spring 3听起来很不错,但它还没有出来,而且Jersey功能齐全,支持开箱即用的SOAP和JSON。 It's all annotation based aside from adding the servlet to your web.xml file which makes it probably easier to configure than even Spring plug-ins, but to avoid getting yelled at, I'll say maybe not. 除了将servlet添加到你的web.xml文件之外,它都是基于注释的,这使得它甚至比Spring插件更容易配置,但是为了避免被大吼大叫,我会说也许不是。
For (MVC) web pages (user UI), I use Spring MVC or Struts. 对于(MVC)网页(用户UI),我使用Spring MVC或Struts。
Spring is great. 春天很棒。 I've used it for some projects and recently also together with Liferay portal server for developing a portlet . 我已将它用于某些项目,最近还与Liferay门户服务器一起用于开发portlet 。
Why is Spring good? 为什么春天好?
All in all, I just had positive experiences, because Spring really promotes best practices. 总而言之,我只是积极的经历,因为Spring真的推广了最佳实践。
I ma monorail MVC user ( castleproject.org), so i guess we come from a similar background. 我是monorail MVC用户(castleproject.org),所以我猜我们来自类似的背景。 A few months ago we started working on the java stack in a different project, particularly with Spring. 几个月前,我们开始在不同的项目中处理java堆栈,尤其是Spring。
Feature wise it s got 90% of what I m used to in monorail, however It is much more flexible, the downside to that is that there is a lot of configuration to get used to. 功能方面它拥有我以前在单轨中使用的90%,但它更加灵活,其缺点是有很多配置需要习惯。 Documentation is extensive sometimes too much so you dont know where to find something. 文档有时太多,所以你不知道在哪里找到东西。 Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.