Java的URL映射類庫 jurlmap
jurlmap是一個Java類庫,能夠讓你的Web應用程序擁有簡潔,類似于REST的URL。
主要特點:
1. URL參數能夠直接綁定至Bean的屬性或方法的參數。
2. 配置直接采用Java編碼或注釋,不需要額外配置文件。
3. URL映射匹配規則簡單。
4. 能夠很方便集成到Web應用程序中,只要將jurlmap提供的過濾器 Filter加到項目就可以。
URL 配置方法:
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); }
本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!