The thinking of struts2 namspace

来源:互联网 发布:starstail for mac 编辑:程序博客网 时间:2024/06/11 10:17

    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.

0 0