Quickly build Web apps with Spring (RESTful API support)

Source: Internet
Author: User
Tags git clone maven central

Spring is a good frame ... One common problem with Java development, however, is that it is too cumbersome to configure earlier. With a new project on hand, I decided to do it in Java, see the new Spring 4, and spring Boot, to make a quick Web Demo. But I don't really like the way I use annotations so much, and Spring 4 comes out a little too soon, so I'm going to do it with spring.

Spring 3 Configuration More, many online articles will teach you step by step to build the environment, involving details is how to say all have. Another uncomfortable point is that some concepts are unclear and unfriendly to the first-time users. Plus my memory is not good, and do not want to start a new project again from the beginning to learn again, so did a Maven archetype, put on Github, named Spring-webapp-restful-quickstart, as the name implies, in addition to support the WEB, You can also support RESTful APIs, like this:

    • Http://localhost:8080/index
      This is the HTML page output
    • Http://localhost:8080/index.json
      This is the output of the JSON data

The above two output only depends on the URL suffix, internal use is the same controller--do not separate for the API dedicated Controller.

API output uses Contentnegotiatingviewresolver, currently the API only supports JSON format output, but to add other formats, such as XML is not difficult, you can change the Applicationcontext.xml The configuration is good.

This skeleton uses Tiles 2 as a template, choose Tiles 2 because it uses JSP as the base language, it is better to use with other tag libraries, and for those familiar with Java to expand it is easier to do their own JSP tag on the line. As for why not choose Tiles 3 ... Because I look at the Tiles 2 feature is enough, no longer see Tiles 3 ... The Jetty is also configured so that you can run the project directly with Maven Jetty:run.

At the moment this archetype just put it on my Github, and after that, some more will be released to the Maven central repository. If you need to, just git clone and install it to the local MAVEN repository using MAVEN installer. Remember to choose Spring-webapp-restful-quickstart when creating a new project with Maven.

Quickly build Web apps with Spring (RESTful API support)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.