码迷,mamicode.com
首页 > 移动开发 > 详细

Spark - A tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effor

时间:2014-11-22 07:06:23      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   color   os   sp   java   for   



bubuko.com,布布扣

Spark - A tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effort

Quick start

import static spark.Spark.*;

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (req, res) -> "Hello World");
    }
}

Run and view

http://localhost:4567/hello

Built for productivity

Spark is a simple and lightweight Java web framework built for rapid development. Spark‘s intention isn‘t to compete with Sinatra, or the dozen of similar web frameworks in different languages, but to provide a pure Java alternative for developers that want to, or are required to, develop in Java.

Spark focuses on being as simple and straight-forward as possible, without the need for cumbersome (XML) configuration, to enable very fast web application development in pure Java with minimal effort. It’s a totally different paradigm when compared to the overuse of annotations for accomplishing pretty trivial stuff seen in other web frameworks, for example, JAX-RS implementations.

Why use Spark?

If you‘re a Java developer with neither the urge nor time to learn a new programming language, and you‘re not planning to build a super large web application that scales in all directions, then Spark might be a great web framework for you. It will have you up and running in minutes, and you won‘t have to think too much about configuration and boilerplate code (like you often have to in other Java web frameworks, like Spring or Vaadin).

Why not use Sinatra?

If you‘re an experienced Ruby developer, or have experience with languages with similar syntax, you should definitely use Sinatra. However, if you‘re a Java developer and want to get the benefits you get from Sinatra without having to learn a new language, Spark is a really good alternative. Spark is a simple and lightweight Java web framework that doesn‘t get in your way!

Why not go with JAX-RS?

JAX-RS made life easier for Java web developers when it arrived. However, it‘s a bit messy due to the overuse of annotations for accomplishing pretty trivial things. The annotation magic also makes things more implicit, and it‘s not always easy to get a clear understanding of what‘s going on. For people who are new to web frameworks and REST, Spark will have you up and running much faster than using one of the JAX-RS implementations.





Spark - A tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effor

标签:style   http   io   ar   color   os   sp   java   for   

原文地址:http://blog.csdn.net/opengl_es/article/details/41376313

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!