Load routes from properties

Splash Forums PrettyFaces Users Load routes from properties

This topic contains 7 replies, has 2 voices, and was last updated by  Christian Kaltepoth 9 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #18979



    i have a very simple static contents website and i needed to change the URLs navigation so instead of having something like this mydomainname/servies/documentum.jsp i did like to have it mydomainname/services/emc

    i have made a properties file contains all needed routes, and i load this route file in getConfiguration method

    and i added them all dynamically like that

    ConfigurationBuilder configurationBuilder = ConfigurationBuilder.begin();

    String routeKey;

    String routeValue;

    for(String key : keysProperties.stringPropertyNames()) {

    routeKey = keysProperties.getProperty(key);

    routeValue = valuesProperties.getProperty(key);



    i have strange case here. i have a route going through this for loop, it will is transmitted to this form


    when i run this case on Tomcat the route doesn’t work (give me HTTP Status 404) and the page is not rendered when i only add front slash at end /de/contact/ it works.

    This case happens with me in only 2 cases, the one i have explained and another one with route looks like this


    1) Can you tell me why does this happen?

    2) can i know what does priority method exactly makes?

    i configured my ConfigurationProvider class only load the route properties one time from the properties file, using if condition,

    3) Is there any other way by the library itself which nables me to run the ConfigurationProvider only once?

    4) I noticed also that the if the route Rule point to name inside anchor like the following example, it doesn’t work also


    Thanks for the great easy library and for help.

    NOTE: i have tried to load this specified route not using properties file just to be sure it not about mis loading of the property and i have defined the rule explicitly like this


    but still doesn’t work


    It ran into a similar problem some time ago. This is actually a container issue.

    If Tomcat receives a request for /de/contact, it first checks if there is a directory with this name deployed with the webapp. This seems to be the case in your example. If Tomcat finds such a directory, it will immediately redirect the user to /de/contact/. But this will typically lead to a 404, because the rule doesn’t match anymore.

    I know that this is totally weird. Some guy on the Tomcat mailing list wrote that this behavior is according to the spec. Unfortunately I don’t know which spec he referred to. Perhaps the Servlet spec? Or some RFC that specifies how to represent directories in an URL? I don’t know.

    However, you can only fix this issue by either added the trailing / to your rule or by renaming the folder deployed with your webapp.

    Let me know if this fixes your problem. :)



    Sorry, I forgot about your other questions:

    The priority methods is used to assign a priority to each rule. The priority of the ConfigurationProvider is the default for all rules. Rules are evaluated in an order defined by this priority. You can use this if you want some rule to be checked before others.

    There is a way to cache the Rewrite configuration so it is only built once. I cannot look up the class name right now. But I think it is something like ConfigurationCacheProvider or so. Have a look at the javadocs. There should be some documentation on how to enable caching.

    Forwarding with an anchor won’t work. An anchor is never send with the request to the server. The anchor is just used by the browser to navigate to a specific part of the page after it has been loaded. So if you want the browser to scroll to a specific point in the page, you have to use the anchor even with the pretty URL.

    I hope this helps. :)




    Thank you for reply,

    i change the name of the folder and it works.

    and regarding the anchor use, i will use rewrite param path and using jquery i will scroll to specified anchor when page is ready.

    That was a great help, and we can signal this post as resolved…



    sorry one last question, i was trying to pass parameter to requested page

    <a href="/solutions/overview?overview=yes">Überblick</a>

    isn’t it right that my Rule shall look like this??


    When i try to make the above code i got 404 Error.

    i don’t know how to apply the parameterized case with rewrite.


    I think in this case you don’t have to add the query parameter to the mapping at all. Just use this:


    I think this should work.



    sorry i have mistyped this part

    i meant it like that.


    and i have tried your suggestion, but it still doesn’t pass the ?overview=yes to the URL as a request parameter.

    but anyways, i worked around this problem by parsing URL using javascrip on page load.

    Thank you for help, and no more question :)


    No problem. Feel free to ask any question you have! :)

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.