Java web framework with RESTful JSON services, HTM

2019-03-16 14:48发布

It is almost year 2013, HTML5 age. jQuery is the de-facto standard for web Javascript-ing.

This link was good for year 2010: https://stackoverflow.com/questions/3882082/rest-json-web-services-java-ee-framework

I am looking for Java web framework that 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.

All web UI processing should be in client browser. Server should just transmit static HTML5 pages. No server-side processing like 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 Java framework that will save time for boilerplate coding of client-server communication.

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." )

Bottom line:

Java web framework + static HTML5 pages + JSON interaction

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-03-16 15:16

Your right it is almost 2013 why not just expose your Rest Web Services with nodeJS!

If your adamant about Java then look at Spring MVC as an alternative to Jax-RS. With Spring (and Jackson for JSON marshall/unmarshall) you can do something like:

@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.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-03-16 15:19

Did you trying exploring Spring for domain-rest mapping and Grails's Scaffolding ? Try exploring these links to achieve your goal :

  1. Domain mapping to REST endpoint
  2. More on domain rest antipattern
  3. Generate whole application using domain model using scaffolding
查看更多
Ridiculous、
4楼-- · 2019-03-16 15:20

I have not found any Java web framework, that would take care of authoring static HTML5 and JavaScript.

For server-side there are Apache CXF, Spring MVC, and a lot other frameworks, that support RESTful web services.

查看更多
登录 后发表回答