Quick Start | Demo Project | Contribute | Donate | FAQ | 中文说明
Blade is a lightweight MVC framework. It is based on the principles of simplicity and elegance. If you like it, please star / fork. Thx 😊
- Lightweight: the code is simple and the structure is clear
- Modular (you can choose which components to use)
- RESTful style routing interface
- Template engine support
- Run with jar file
- JDK8+
- Simplicity: The design is simple, easy to understand and doesn't introduce many layers between you and the standard library. The goal of this project is that the users should be able to understand the whole framework in a single day.
- Elegance:
blade
supports the RESTful style routing interface, has no invasive interceptors and provides the writing of DSL grammar.
To get started, first include the Blade library :
Grab via Maven
:
<dependency>
<groupId>com.bladejava</groupId>
<artifactId>blade-core</artifactId>
<version>1.7.2-alpha</version>
</dependency>
<dependency>
<groupId>com.bladejava</groupId>
<artifactId>blade-embed-jetty</artifactId>
<version>0.1.3</version>
</dependency>
or Gradle
:
compile 'com.bladejava:blade-core:1.7.2-alpha'
compile 'com.bladejava:blade-embed-jetty:0.1.3'
Create Main
method like this:
public static void main(String[] args) {
$().get("/", (request, response) -> {
response.html("<h1>Hello blade!</h1>");
}).start(Application.class);
}
Run it and point your browser to http://localhost:9000. There you go, you've just created your first Blade app!
public static void main(String[] args) {
$().get("/user/21", getxxx);
$().post("/save", postxxx);
$().delete("/del/21", deletexxx);
$().put("/put", putxxx);
}
public static void main(String[] args) {
$().get("/user/:uid", (request, response) -> {
Integer uid = request.paramAsInt("uid");
response.text("uid : " + uid);
});
$().get("/users/:uid/post/:pid", (request, response) -> {
Integer uid = request.paramAsInt("uid");
Integer pid = request.paramAsInt("pid");
String msg = "uid = " + uid + ", pid = " + pid;
response.text(msg);
});
$().start(Application.class);
}
public static void main(String[] args) {
$().get("/user", (request, response) -> {
Integer uid = request.queryAsInt("uid");
response.text("uid : " + uid);
}).start(Application.class);
}
public void upload_img(@MultipartParam FileItem fileItem){
if(null != fileItem){
File file = fileItem.getFile();
String fileRealPath = "your upload file path!";
nioTransferCopy(file, fileRealPath);
}
}
route.conf
GET / IndexRoute.home
GET /signin IndexRoute.show_signin
POST /signin IndexRoute.signin
GET /signout IndexRoute.signout
POST /upload_img UploadRoute.upload_img
public static void main(String[] args) {
$().before("/.*", (request, response) -> {
System.out.println("before...");
}).start(Application.class);
}
You may refer to these examples for additional guidance:
- BBS:https://java-china.org
- Gallery:https://nice.biezhi.me
- SS Panel:https://github.com/biezhi/ss-panel
- Doc Site:https://bladejava.com
- Blog:http://biezhi.me
- Mail: biezhi.me@gmail.com
Thank you very much for the developers to help in the project, if you are willing to contribute, welcome!
Please see Apache License