Basically, I just want to match a url pattern that doesn't follow the normal path-hierarchy that Java EE url pattern matching seems to follow. I want to be able to handle matching a url pattern that is updated somewhat frequently. For example, I have a table in a database with a list of categories. I want to match url patterns like this:
@WebServlet(urlPatterns={"/category-1/*", "/category-2/*", "/category-3/*", "/category-4/*", "/category-5/*", "/category-6/*", ...})
and so on until I've covered all the rows in my table. I'm wondering if it's possible to instead automate building the list from the database then dynamically passing it into urlPatterns()
. If this isn't possible, is there maybe some sort of regex based alternative to matching url patterns? I really just want my URL to look like this: https://mywebsite.com/category-name-1/some-article
so that I can have the category name as the first prefix in the URL path-hierarchy even though there could be 60-70 potential matches in my category table.