首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2.x 与struct 1.x 差别

2012-06-27 
struts2.x 与struct 1.x 区别1. 入口不同strut1 入口是servlet,struts 2 入口为filter下面是在web.xml 中

struts2.x 与struct 1.x 区别

1. 入口不同

strut1 入口是servlet,struts 2 入口为filter

下面是在web.xml 中配置Struts2的代码:?
<filter>?
<filter-name>struts2</filter-name>?
<filter-class>?
org.apache.struts2.dispatcher.FilterDispatcher?
</filter-class>?
</filter>?
<filter-mapping>?
<filter-name>struts2</filter-name>?
<url-pattern>/*</url-pattern>?
</filter-mapping>?

2.继承类不同,struts1 继承Action,Struts2 继承ActionSupport

3.execute()方法 参数不同,strut1 有四个,struts2 没有

4.actionForm ,struts1 一定要actionForm 接受用户输入,而strut2 将它集成与action 中,更简洁(actionForm 就是一堆get()、set)

5. 配置文件内容及位置不同,在struts1.x中的配置文件一般叫strutsconfig.xml(当然也可以是其他的文件名),而且一般放到WEB-INF目录中。而在struts2.xml中的配置文件一般为struts.xml,放到WEB-INF"classes目录中

6.动作结尾不同,Struts1.x的动作一般都以.do结尾,而Struts2是以.action结尾。?

?

参考博客?http://wzhiju.iteye.com/blog/1118669

热点排行