Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework!

POJO controllers
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
TextTools.java
@Controller
public class TextTools {
 
    @GET("/upper/{s}")
    public Map<String, String> upper(String s) {
        String big = s.toUpperCase();
        return U.map("normal", s, "big", big);
    }
 
    @POST
    public String[] parts(String text) {
        return text.split("-");
    }
 
}
GET /upper/abc
{"normal":"abc","big":"ABC"}
POST /parts {"text":"just-some-words"}
["just","some","words"]

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
POST /parts main json
GET /upper/{s} main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Book.java
public class Book {
 
    public String title = "Untitled";
 
    private int year;
 
    public int getYear() {
        return year;
    }
 
    public void setYear(int year) {
        this.year = year;
    }
}
EasyBeans.java
@Controller
public class EasyBeans {
 
    @GET
    public Book echo(Book book) {
        return book;
    }
 
}
GET /echo?year=2012&title=Abc
{"title":"Abc","year":2012}
GET /echo?year=2015
{"title":"Untitled","year":2015}

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /echo main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Bar.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
 
import javax.inject.Inject;
 
@Controller("/bar")
public class Bar {
 
    @Inject
    public Foo foo;
 
    @GET("/hi")
    public String hello() {
        return foo.msg();
    }
 
    public String msg() {
        return "Hello from Bar!";
    }
 
}
Foo.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
 
import javax.inject.Inject;
 
@Controller("/foo")
public class Foo {
 
    @Inject
    public Bar bar;
 
    private int count;
 
    @GET("/hi")
    public String hello() {
        return ++count + ": " + bar.msg();
    }
 
    public String msg() {
        return "Hello from Foo!";
    }
 
}
GET /foo/hi
"1: Hello from Bar!"
GET /bar/hi
"Hello from Foo!"
GET /foo/hi
"2: Hello from Bar!"

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /bar/hi main json
GET /foo/hi main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
SubUrlParams.java
@Controller
public class SubUrlParams {
 
    @GET("/hey/{name}/{age:\\d+}")
    public String hey(String name, int age) {
        return U.frmt("Hey %s (%s)", name, age);
    }
 
    @POST("/size/{s}")
    public int size(String s) {
        return s.length();
    }
 
}
GET /hey/Joe/50
"Hey Joe (50)"
GET /hey/You!/123
"Hey You! (123)"
POST /size/abc
3

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /hey/{name}/{age:\d+} main json
POST /size/{s} main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
NamedParams.java
@Controller
public class NamedParams {
 
    @GET
    public int sum(int x, @Param("y") int z) {
        return x + z;
    }
 
}
GET /sum?x=1&y=2
3
GET /sum?y=10&x=5&z=12345
15

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /sum main json
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
Hello.java
@Controller
public class Hello {
 
    @Page("/")
    public String hello() {
        return "Hello, world!";
    }
 
}
GET /
Hello, world!
POST /
Hello, world!

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST / main html index
Main.java
import org.rapidoid.setup.App;
 
public class Main {
 
    public static void main(String[] args) {
        App.bootstrap(args);
    }
 
}
YourName.java
@Controller
public class YourName {
 
    @Page("/hi/{name}")
    public Screen hi(String name) {
        Tag msg = GUI.h4("Hi, ", GUI.i(name), "!");
        return GUI.page(msg).brand("What is your name?");
    }
 
}
GET /hi/Rapidoid

Hi, Rapidoid!

POST /hi/there

Hi, there!

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET POST /hi/{name} main html hi/name