#Blade
blade Is a concise and powerful web development framework, it is built into the IOC administration, the interceptor configuration, REST API development and so on many mainstream web features, integrate the template engine, a cache plug-in, database operations, commonly used functions such as email, concise source deserves your reading. If you like it, can be Star and Fork, thanks!
- Simple MVC
- Restful
- Multiple routing configuration
- Micro kernel IOC container
- Utility class
- Coding/JSON/configuration file
- JDK1.6 +
- Plug-in extension mechanism
- Template engine Plugin
- Cache Plugin
- The source code of less than 100kb
First. Use maven to build a webapp, join dependency on the blade,Recommended for the latest version
<dependency>
<groupId>com.bladejava</groupId>
<artifactId>blade-core</artifactId>
<version>1.2.7-alpha</version>
</dependency>Second. Configuration in the web.xml Blade core filter initialization and set your class, and you can also not configuration(using jetty start)
<filter>
<filter-name>BladeFilter</filter-name>
<filter-class>blade.BladeFilter</filter-class>
<init-param>
<param-name>applicationClass</param-name>
<param-value>hello.App</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>BladeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>Third. Write App.java and routing file, here is an example
public class App extends BladeApplication{
Logger logger = Logger.getLogger(App.class);
@Override
public void init() {
// register router
Blade.regRoute("/hello", SayHi.class, "hello");
// anonymous router,java8 so simple
Blade.get("/get", new RouteHandler() {
@Override
public String run(Request request, Response response) {
System.out.println("come get!!");
System.out.println(request.query("name"));
return "get";
}
});
}
}public class SayHi {
public String hello(Request request, Response response){
System.out.println("come hello~");
request.attribute("name", "rose baby");
return "hi";
}
}@Path("/")
public class Hello {
@Route("hello")
public String hello() {
System.out.println("hello");
return "hello.jsp";
}
@Route(value = "post", method = HttpMethod.POST)
public void post(Request request) {
String name = request.query("name");
System.out.println("name = " + name);
}
@Route("users/:name")
public ModelAndView users(Request request, Response response) {
System.out.println("users");
String name = request.pathParam(":name");
ModelAndView modelAndView = new ModelAndView("users");
modelAndView.add("name", name);
return modelAndView;
}
@Route("index")
public String index(Request request) {
request.attribute("name", "jack");
return "index.jsp";
}
}OK, all this may seem simple, refer to the guidelines for use more ready-made examples for your reference:
1. Improve the document
2. Single user blog system development
3. web chat system
4. Optimize the code performance
Blade Framework based on the Apache2 License
OSC Blog:http://my.oschina.net/biezhi
Mail: biezhi.me#gmail.com
QQ Group: 1013565
