天天看点

【Struts框架】第一节Action-模块包含和defaultAction

1.模块包含:

struts.xml:

里面可以这么写

<include file="login.xml"></include>

说明在struts.xml包含了一个login.xml文件

login.xml:

及相当于在struts.xml文件中添加了login.xml的内容

这个东西应用的场景:

多人开发的情况,每个人在各自不同的机器上开发,可以写xml文件,最后整合的时候将所有模块的xml文件组合在一个struts文件中(将公用配置设置在struts.xml中)

2.defaultaction:

如果找不到对应的action或者敲action的时候,是访问不到action的,这个时候会报错。所以我们要设置默认的action给用户一个友好界面,防止这种情况的发生。

struts中这样配置:

当输入action为空或者错误名时,就会跳转到default.jsp这个友好提示界面

如:

http://localhost:8080/struct2_0100_introduction/

或者:

http://localhost:8080/struct2_0100_introduction/faasa(不存在的action)

跳转到default.jsp:

转载请注明出处:http://blog.csdn.net/acmman/article/details/44463511