自己实现蝇量级Java MVC框架

Tiny Java MVC Framework.

Requirements

  • Java8+

Dependency

Apache Maven

1
2
3
4
5
复制代码`<dependency>`
<groupId>com.nosuchfield</groupId>
<artifactId>geisha</artifactId>
<version>1.0.0-RELEASE</version>
</dependency>

Apache Buildr

1
复制代码`'com.nosuchfield:geisha:jar:1.0.0-RELEASE'`

Apache Ivy

1
复制代码`<dependency org="com.nosuchfield" name="geisha" rev="1.0.0-RELEASE" />`

Groovy Grape

1
2
3
复制代码`@Grapes(` 
@Grab(group='com.nosuchfield', module='geisha', version='1.0.0-RELEASE')
)

Gradle/Grails

1
复制代码`compile 'com.nosuchfield:geisha:1.0.0-RELEASE'`

Scala SBT

1
复制代码`libraryDependencies += "com.nosuchfield" % "geisha" % "1.0.0-RELEASE"`

Leiningen

1
复制代码`[com.nosuchfield/geisha "1.0.0-RELEASE"]`

Example

1
2
3
4
5
6
7
8
9
10
复制代码@Component
@RequestMapping("/person")
public class Hello {

@RequestMapping("/info")
public String hello(@Param("name") String name, @Param("age") String age) {
return "hello " + name + ", your age is " + Integer.valueOf(age);
}

}
1
2
3
4
5
6
7
复制代码public class Application {

public static void main(String[] args) {
Geisha.run();
}

}

Run Application and visit http://127.0.0.1:5200/person/info?name=张三&age=18

Result:

1
复制代码`hello 张三, your age is 18`

License GPL

Project License can be found here.

本文转载自: 掘金

开发者博客 – 和开发相关的 这里全都有

0%