The thinking of struts2 namspace

本文探讨了Struts2框架中命名空间的概念及其作用。解释了为何某些情况下JSP可以省略命名空间,而XML配置文件中却需要指定。通过类比的方法,使读者更好地理解如何使用命名空间定位Action。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值