Java的URL映射类库 jurlmap
fmms
13年前
<p><img title="jurlmap_logo.png" border="0" alt="jurlmap_logo.png" src="https://simg.open-open.com/show/c80adcf43262755677b8c86d674c8436.png" width="120" height="42" /><br /> jurlmap是一个Java类库,能够让你的Web应用程序拥有简洁,类似于REST的URL。</p> <p>主要特点:</p> <p>1. URL参数能够直接绑定至Bean的属性或方法的参数。<br /> 2. 配置直接采用Java编码或注释,不需要额外配置文件。<br /> 3. URL映射匹配规则简单。<br /> 4. 能够很方便集成到Web应用程序中,只要将jurlmap提供的过滤器 Filter加到项目就可以。</p> <p>URL 配置方法:</p> <pre class="brush:java; toolbar: true; auto-links: false;">protected void configure() { // In this pattern $ means a string, which when matched // is bound to parameter `Username` and control forwarded to profile.jsp // Parameter will be accessible via request.getParameter() forward("/profile.jsp", "/profile/$Username"); // Here % means integer pattern and * means until end of the pattern. // Binds integers to parameter ArticleId and forwards to article.jsp forward("/article.jsp", "/article/%ArticleId/*"); // When matched will send a redirect back to browser and parameters // are appended to query string so in this case the target will // be `/servlets/profileservlet?Username=...` redirect("/servlets/profileservlet", "/member/$Username"); // On match creates an instanc eof LoginPage and calls it's service method // LoginPage class implements com.pagegoblin.jurlmap.Page. // If it is annotated with a @Deploy(url) annotation // the we don't need to pass a url to the deploy method. // In this case parameters are bound to bean properties or fields // of the newly created LoginPage instance. deploy(LoginPage.class); }</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1323612203561" target="_blank">http://www.open-open.com/lib/view/home/1323612203561</a></p> <p></p>