Struts2的访问路径为什么可以用.action或不写,以及Struts2访问路径的搜索方式

来源:互联网 发布:死神辣条淘宝 编辑:程序博客网 时间:2024/05/16 06:04

1.问:为何href里请求路径的格式可以写action也可不写?

<a href="User_save.action">User-Save</a><a href="User_delete">User-Delete</a>

答:原因是:struts2-core-2.2.1.jar下的org.apache.struts2包下的default.properties
        配置了struts.action.extension=action,,     即:既可以.action结尾,也可以不写


2.问:为何访问http://localhost:9090/struts2_day1/a/b/c/helloAction也能正确访问页面?

答:struts2在搜索名称空间的时候

(1)/a/b/c/下有无helloAction   无

(2)/a/b/下有helloAction      无

(3)/a/下有无helloAction         无

(4)/下有无helloAction            有