对于类似于 Ruby On Rails的URI影射方式,Java Web开发也可以实现。参考
http://code.google.com/p/jmap/
假定有这样一个URI: /jmap/main/login,这里web context path是"/jmap",servlet mapping是"
/main/*",这样的URI会被一个有预定包前缀的类package.prefixname.controller.Main的Login方法所响应。大概有以下的样例代码:
web context path是会随着发布的不同而变化的,所以不能作为影射规则的一部分。如果有另一个servlet mapping "/product/*",则URI: /jmap/product/list/category1会被影射到package.prefixname.controller.Product类的List方法,URI中的"category1"会作为类成员数据urlHint传递给Main类。
目前,该框架还提供了基于annotation的form数据影射和验证方法。