difference between Struts 1.x and Struts 2.x

The major difference is that in Struts1.x the request directly goes to the servlet, whereas in Struts2.xthe request and response traval though the stack of interceptor or filter. The regular logic can be placed in Filter classes and developer can concentrate on the Business Logic. Besides this there is also differences in directory structure.

It is better to know the differences between Struts1.x and Struts2.x topic wise. Here's a cite ofhttp://www.geekinterview.com/question_details/64360:


1. Action Classes

In Struts 1.x the action classes should extend Action (or DispatchAction) class and the execute method have number of parameter and a ActionForward return type , but In struts 2.x the action class can also be simple pojo having execute method returning only a string without any input parameter.


2. Servlet Dependancy

Container does not treat Struts2.x, unlike that of Struts1.x, Actions as a request / response couple andstruts2.x action can still access the original request and response.


3. Getting Input

  • In Struts1.x form beans are used to define properties, getters & setters, in struts2.x getters/setters are defined in action classes itself.
  • Struts1.x form beans class must extend ActionForm or ValidatorForm, but Struts2.x beans can also be POJO.

4. Testability

  • In Struts1.x execute() method exposes the servlet API for testing.
  • Struts2.x Dependancy Injection be used to simplify the testing process.

5. Expression Languages

  • Struts1.x JSTL as its expression language, where as Struts2.x uses OGNL(Object Graphic Notation Language) as its expression language which is very strong than JSTL.
  • Struts2.x can also use JSTL.

6. Type Conversion

  • In Struts1.x properties are almost in String form, Convertors are per class which are not configurable.
  • Struts 2.x uses OGNL for type conversion

7. Validation

Server side validation are made in action classes in Struts2.x, a much simpler way.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值