struts2 Namespace configuration when set a specific context-root

陌路散爱 提交于 2019-12-08 04:25:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!