jurlmap是一个Java类库,能够让你的Web应用程序拥有简洁,类似于REST的URL。
主要特点:
1.URL参数能够直接绑定至Bean的属性或方法的参数。2.配置直接采用Java编码或注释,不需要额外配置文件。3.URL映射匹配规则简单。4.能够很方便集成到Web应用程序中,只要将jurlmap提供的过滤器Filter加到项目就可以。
URL配置方法:
protectedvoidconfigure(){ //Inthispattern$meansastring,whichwhenmatched //isboundtoparameter`Username`andcontrolforwardedtoprofile.jsp //Parameterwillbeaccessibleviarequest.getParameter() forward("/profile.jsp","/profile/$Username"); //Here%meansintegerpatternand*meansuntilendofthepattern. //BindsintegerstoparameterArticleIdandforwardstoarticle.jsp forward("/article.jsp","/article/%ArticleId/*"); //Whenmatchedwillsendaredirectbacktobrowserandparameters //areappendedtoquerystringsointhiscasethetargetwill //be`/servlets/profileservlet?Username=...` redirect("/servlets/profileservlet","/member/$Username"); //OnmatchcreatesaninstanceofLoginPageandcallsit'sservicemethod //LoginPageclassimplementscom.pagegoblin.jurlmap.Page. //Ifitisannotatedwitha@Deploy(url)annotation //thewedon'tneedtopassaurltothedeploymethod. //Inthiscaseparametersareboundtobeanpropertiesorfields //ofthenewlycreatedLoginPageinstance. deploy(LoginPage.class);}
评论