问题
When I set a context-root in weblogic.xml for my application, what is the default namespace for package in struts2?
ex:
I set <context-root>/home/app/exec</context-root>
and I access my app with the following uri: localhost:8081/home/app/exec/index.html
insted of localhost:8081/NameOfMyApp/index.html
In the other hand I Know that in Struts2 action namespace map to folder structure. Example on the following link: https://www.mkyong.com/struts2/struts-2-namespace-configuration-example-and-explanation/
What is the correct namespace for the situation in case that ServletContext
is not the name of my app but is the context-root?
回答1:
Namespace is the part that is calculated after the context path and before the action name. On the other hand a namespace is an attribute of the package that holds the actions belonging that namespace. A default action mapper is using both attributes to find the action config corresponding the namespace and action name.
For detailed explanation of default action mapper you can read javadocs DefaultActionMapper.
You can read more about action configuration and ActionMapper on the Struts docs site.
You should also know that the action mapper returns ActionMapping. However, to execute an action requires ActionConfig which is determined by the Struts using run-time configuration.
来源:https://stackoverflow.com/questions/42491366/struts2-namespace-configuration-when-set-a-specific-context-root