带有 RESTful JSON 服务、HTML5 和 jQuery ajax 的 Java Web 框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13874034/
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
Java web framework with RESTful JSON services, HTML5 & jQuery ajax
提问by Paul Verest
It is almost year 2013, HTML5 age. jQuery is the de-facto standard for web Javascript-ing.
快到 2013 年了,HTML5 时代。jQuery 是 web Javascript 的事实上的标准。
This link was good for year 2010: https://stackoverflow.com/questions/3882082/rest-json-web-services-java-ee-framework
此链接适用于 2010 年:https: //stackoverflow.com/questions/3882082/rest-json-web-services-java-ee-framework
I am looking for Java web frameworkthat will expose domain classes via RESTful JSON web services. Then will [hopefully] generate web forms for those domain classes. And uses jQuery ajax to communicate with server for sending/receiving JSON data and populate in HTML.
我正在寻找将通过 RESTful JSON Web 服务公开域类的Java Web 框架。然后将 [希望] 为这些域类生成 Web 表单。并使用 jQuery ajax 与服务器通信以发送/接收 JSON 数据并填充 HTML。
All web UI processing should be in client browser. Server should just transmit static HTML5 pages. No server-side processing like JSP.
所有 Web UI 处理都应在客户端浏览器中进行。服务器应该只传输静态 HTML5 页面。没有像 JSP 那样的服务器端处理。
UPDATE. I must clarify that my question point is not what framework to use for web-services creation. (There are a lot like Apache CXF, Spring MVC web services). It is not also about jQuery or not. But Javaframework that will save time for boilerplate coding of client-server communication.
更新。我必须澄清,我的问题不是用于创建 Web 服务的框架。(有很多像 Apache CXF、Spring MVC 的 web 服务)。它也不是关于 jQuery 与否。但是Java框架将为客户端-服务器通信的样板编码节省时间。
Groovy & Scala are great things, but they are not Java, but JVM languages. (Imagine telling your teammates "We should learn Java-like language with some differences to start using a new framework." )
Groovy 和 Scala 是很棒的东西,但它们不是 Java,而是 JVM 语言。(想象一下告诉你的队友“我们应该学习类似 Java 的语言,但有一些差异,才能开始使用新框架。”)
Bottom line:
底线:
Java web framework+ static HTML5 pages+ JSON interaction
Java web 框架+静态 HTML5 页面+ JSON 交互
回答by Saurabh
Did you trying exploring Spring for domain-rest mapping and Grails's Scaffolding ? Try exploring these links to achieve your goal :
您是否尝试探索 Spring 的域休息映射和 Grails 的脚手架?尝试探索这些链接以实现您的目标:
回答by ramsinb
Your right it is almost 2013 why not just expose your Rest Web Services with nodeJS!
您的权利几乎是 2013 年,为什么不直接使用nodeJS公开您的 Rest Web 服务!
If your adamant about Java then look at Spring MVC as an alternative to Jax-RS. With Spring (and Hymanson for JSON marshall/unmarshall) you can do something like:
如果您坚持使用 Java,那么将 Spring MVC 视为 Jax-RS 的替代品。使用 Spring(和 Hymanson for JSON marshall/unmarshall),您可以执行以下操作:
@Controller
@RequestMapping("/resource")
public class ResourceController
{
@Autowired
private ResourceService resourceService;
@RequestMapping(value="/{id}", method=RequestMethod.GET)
public @ResponseBody Resource getResource(@PathVariable Integer id)
{
return resourceService.lookup(id);
}
...
}
public class Resource
{
@JsonProperty("id")
private int id;
@JsonProperty("resourceName")
private String name;
...
}
Hope that helps.
希望有帮助。
回答by Paul Verest
I have not found any Javaweb framework, that would take care of authoring static HTML5 and JavaScript.
我还没有找到任何JavaWeb 框架来处理静态 HTML5 和 JavaScript 的创作。
For server-side there are Apache CXF, Spring MVC, and a lot other frameworks, that support RESTful web services.
对于服务器端,有 Apache CXF、Spring MVC 和许多其他支持 RESTful Web 服务的框架。