In the lastduring, I am studying the basic about struts2.
At be ginning,I always am confused by the namespace of struts2 xml configuration file.
Cause, sometimes I shall read some examplesthat have namespace in configuration file but no the namespace in action of JSP.
However, the definition of namespace is a path tofind action. Therefore, I feel it is strange why JSP has no namespace ratherstruts xml could have?
Think in a second, then I read references some,finally, I could think me to be a little clear about the namespace. Cause thenamespace has another function that is to recognize same name action in oneproject.
In the while, the request sends a order to action,and must have a action receive the order and to execute it. In the time, whocould receive this order? It will be judged by the namespace. The method that findsthe action in the struts xml file is to use relative path ,that is afterrequest’s current path is followed by namespace and action name.
Take one example, a commanding officer will give aorder to A, concurrently, it has each an A in NO.1 troop and NO.2 troop. So thiscommanding officer could give the order, if he is in any a troop. If he were inown office, he would have specific troop’s A.
At now, struts2 also is same with the commander. Whenit give a order to a result in same package, JSP could omit the namespace. But whenthis result cannot exist in same package, JSP’s action would not have to omitnamespace. Otherwise, the server would throw a wrong that could not find pathof action.
本文探讨了Struts2框架中命名空间的概念及其作用。解释了为何某些情况下JSP可以省略命名空间,而XML配置文件中却需要指定。通过类比的方法,使读者更好地理解如何使用命名空间定位Action。
2993

被折叠的 条评论
为什么被折叠?



