Reputation: 2624
I'm currently developing a Struts 2 web application that allow anonymous usage. I want that with anonymous user, the URL will be like:
http://localhost:8080/myapp
But after user logged in, the URL will be personalized base on user name, for example:
http://localhost:8080/myapp/Cuong-Doan
Please suggest me a plugin/technique that can help me to achieve it.
Upvotes: 0
Views: 443
Reputation: 1
Personalized could be done via setting the parameter specifying the persona. Looking at the URLs in the question I decided to give you imagination about technique used to reproduce SEO optimized URLs. This technique is called "Parameters after action names". For example to map your persona with the action you can use
@Action(value = "/*", params = {"person", "{1}"})
so, after that action is mapped you will get the information about person via the person
parameter that could be used in the action.
Upvotes: 1
Reputation: 7817
You can try to do it with Tuckey's UrlRewriteFilter. After loging add session attribute, for example loggedUsername=Cuong-Doan
. Then analyze this attribute in UrlRewriteFilter rule using session-attribute
parameter of condition element. If it is present -> do redirect, add it to the URL using backreferences.
Upvotes: 1