---
title: "造了个轮子，更新2.0版了:-)，firefly一站式java web框架"
author: "hypercube1024"
date: "2012-10-30T20:48:56Z"
tags: []
categories: ["开源软件"]
slug: "2-0-firefly-java-web"
draft: false
lastmod: "2012-10-30T20:48:56Z"
id: 1709122
url: "https://hypercube1024.iteye.com/blog/1709122"
---

# 特性

- firefly是一个高性能的web开发框架，Template engine，IOC、MVC framework，HTTP Server，Common tools，Log，Json parser等模块一应俱全。
- 使用简单，无侵入。
- 仅仅依赖jdk，完全不会引入第三方库。
- 高性能，在我的macbook上轻松达到3W+ req/s
- 完全开源，[源码地址](https://github.com/hypercube1024/firefly "https://github.com/hypercube1024/firefly")

# 主页

[http://www.fireflysource.com](http://www.fireflysource.com "http://www.fireflysource.com")

 

github: [https://github.com/hypercube1024/firefly](https://github.com/hypercube1024/firefly "https://github.com/hypercube1024/firefly")

google code: [http://code.google.com/p/firefly/](http://code.google.com/p/firefly/ "http://code.google.com/p/firefly/")

 

# HelloWorld

## 创建Controller

```
@Controller
public class IndexController {
	@RequestMapping(value = "/document/?/?")
	public View document(HttpServletRequest request, @PathVariable String[] args) {
		request.setAttribute("info", args);
		return new TemplateView("/index.html");
	}
}
```

## 创建模版

```
<!DOCTYPE html>
<html>
<body>
${info[0]},${info[1]}
</body>
</html>
```

## 创建firefly配置

```
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://code.google.com/p/firefly/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://code.google.com/p/firefly/beans http://firefly.googlecode.com/files/beans.xsd">

	<component-scan base-package="com.firefly"/>
	<mvc view-path="/template" view-encoding="UTF-8"/>

</beans>
```

 

## 创建Log配置

```
firefly-system=INFO,/Users/qiupengtao/develop/logs
firefly-access=INFO,/Users/qiupengtao/develop/logs
```

 

## 创建Main函数

```
public class Bootstrap {

	public static void main(String[] args) throws Throwable {
		String projectHome = new File(Bootstrap.class.getResource("/").toURI()).getParent();
		String serverHome = new File(projectHome, "/page").getAbsolutePath();
		ServerBootstrap.start(serverHome, "localhost", 6655);
	}

}
```

 

启动main函数，访问 http://localhost:6655/document/pengpeng/1234，页面就会显示出pengpeng, 1234。

Template engine，IOC、MVC framework，HTTP Server，Common tools，Log，Json parser等模块具体使用可光临[firefly主页](http://www.fireflysource.com/ "firefly主页")