Java/Struts2: How to get action name from current url
java, struts2
Solution
Did you look for `ActionContext#getName()` ?
Edit : Since you were not clear about it, I suppose you want to get the name of the action being executed from inside the action. So, in your action `execute` method, you'll have something like this :
String actionName = ActionContext.getContext().getName();
Problem
I am having a active page with its url like `http://localhost:8085/projectName/namespace1/namespace2/namespace3/sell.action?id=22` Now i want get the action name(4th name after the sign `/`) i.e setuppageforwared. How to achieve this ? Please help me to know because i read many books of struts2 i could not find anything which solve this problem. Before i was using PHP framework `codeigniter` which easily solve this type of problem using uri segment features(click here) . I am aspecting the same here in Struts2. Given Url String: `http://localhost:8085/projectName/namespace1/namespace2/namespace3/sell.action?id=22` Expected Output: `sell`