TornadoJJAVA Web 框架
TornadoJ 是一个纯 JAVA Web 框架,小巧精致,依赖很少,易于使用和内嵌到现有系统中。
@WebModule(name = "user") public class RouteTest { private final static Logger Log = Logger.getAnonymousLogger(); /** * url:/user/profile/1.html * * @param context */ @Route(name = "profile", paramPatterns = "\\d+") public void profile(HttpContext context) { int id = context.paramInt(0); Log.info(String.format("%d", id)); context.putData("userId", id); context.render("nolayout.ftl"); } /** * url:/user/business/vip-2.html * * @param context */ @Route(name = "/business", paramPatterns = "\\w+-\\d+", paramExtractor = "\\w+") public void business(HttpContext context) { String type = context.param(0); int id = context.paramInt(1); Log.info(String.format("%s", type)); Log.info(String.format("%d", id)); context.render("testlayout.ftl"); } /** * Url: /user/financial/2013-11-11_2014-11-11.html * * @param context */ @Route(name = "/financial", paramPatterns = "\\d{4}-\\d{2}-\\d{2}_\\d{4}-\\d{2}-\\d{2}", paramExtractor = "\\d{4}-\\d{2}-\\d{2}") public void financial(HttpContext context) { Date from = context.paramDate(0, "yyyy-MM-dd"); Date to = context.paramDate(1, "yyyy-MM-dd"); Log.info(DateFormatUtils.format(from, "yyyy/MM/dd")); Log.info(DateFormatUtils.format(to, "yyyy/MM/dd")); context.putData("fromDate", from); context.putData("toDate", to); context.render("testlayout.ftl"); } }
评论