频道栏目
首页 > 资讯 > 其他 > 正文

SSH框架之Struts的默认访问后缀、相同访问路径问题、常量

17-01-04        来源:[db:作者]  
收藏   我要投稿

一、Struts中默认访问后缀:
1、Struts1中默认访问后缀是*.do
2、Struts2中默认访问后缀是*.action

3、如何修改默认访问后缀:
1)Struts2的.action访问后缀在哪里定义?
Struts-core-2.3.4.1.jar/org.apache.struts/default.properties中的

struts.action.extension=action,,

2)在struts.xml中进行对常量的修改
所有的项目都要使用,是一个全局配置,所以位置应该位于:
标签的后面,标签的前面!


4、情况分析

value="action,,"
    localhost:8080/struts_02/user_register          OK
    localhost:8080/struts_02/user_register.action   OK

value="action," 或 value="action"
    localhost:8080/struts_02/user_register.action   OK

value="action,do,"
    localhost:8080/struts_02/user_register          OK
    localhost:8080/struts_02/user_register.do       OK
    localhost:8080/struts_02/user_register.action   OK

value="action,do"
    localhost:8080/struts_02/user_register.do       OK
    localhost:8080/struts_02/user_register.action   OK

二、相同访问路径问题
问题产生:
1、Action

2、struts.xml


    /index.jsp



    /index.jsp

3、由于上述情况,所以二者想要访问register方法的访问路径均为:
http://localhost:8080/struts_02/user_register

结果:
当我们访问此路径时,运行情况到底如何?

由此可见,配置在前面的会被配置在后面的覆盖掉

三、Struts中的常量(Struts-core-2.3.4.1.jar/org.apache.struts/default.properties中)
1、详解:



















 






2、应用:动态方法调用(不推荐使用,原因:这种形式,需要对程序结构有所了解,不安全)
1、动态方法调用语法:action name+!+方法名
2、举例:

相关TAG标签
上一篇:0-构建Docker
下一篇:[POJ1474]Video Surveillance(半平面交)
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站