主题比较中心
Struts 1 对比 Struts 2
通过结构化对比表查看 Struts 1 与 Struts 2 的差异,然后继续浏览相关面试题、测验以及类似主题比较。
10
比较要点
2
相关比较
主题对比
Struts 1 与 Struts 2 的对比有助于你理解哪一种更适合自己的使用场景。这里也整理了 Struts 2 和 Struts 1 的常见对比内容,适用于面试准备。
比较概览
Struts 1 与 Struts 2 的区别
Struts 1 与 Struts 2 的对比有助于你理解哪一种更适合自己的使用场景。这里也整理了 Struts 2 和 Struts 1 的常见对比内容,适用于面试准备。
Struts 1
本次并排比较中的主题一。
10
当前页面可用的比较条目。
Struts 2
本次并排比较中的主题二。
|
Struts 1
|
Struts 2
|
|---|---|
| Action Classes: Struts 1 requires Action classes to extend an abstract base class. A common problem in Struts 1 is programming to abstract classes instead of interfaces. | Action Classes: An Struts 2 Action may implement an Action interface, along with other interfaces to enable optional and custom services. Struts 2 provides a base ActionSupport class to implement commonly used interfaces. Albeit, the Action interface is not required. Any POJO object with a execute signature can be used as an Struts 2 Action object. |
| Threading Model: Struts 1 Actions are singletons and must be thread-safe since there will only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. Action resources must be thread-safe or synchronized. | Threading Model: Struts 2 Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containers generate many throw-away objects per request, and one more object does not impose a performance penalty or impact garbage collection.) |
| Servlet Dependency: Struts 1 Actions have dependencies on the servlet API since the HttpServletRequest and HttpServletResponse is passed to the execute method when an Action is invoked. | Servlet Dependency: Struts 2 Actions are not coupled to a container. Most often the servlet contexts are represented as simple Maps, allowing Actions to be tested in isolation. Struts 2 Actions can still access the original request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServletResponse directly. |
| Testability: A major hurdle to testing Struts 1 Actions is that the execute method exposes the Servlet API. A third-party extension, Struts TestCase, offers a set of mock object for Struts 1. | Testability: Struts 2 Actions can be tested by instantiating the Action, setting properties, and invoking methods. Dependency Injection support also makes testing simpler. |
| Harvesting Input: Struts 1 uses an ActionForm object to capture input. Like Actions, all ActionForms must extend a base class. Since other JavaBeans cannot be used as ActionForms, developers often create redundant classes to capture input. DynaBeans can used as an alternative to creating conventional ActionForm classes, but, here too, developers may be redescribing existing JavaBeans. | Harvesting Input: Struts 2 uses Action properties as input properties, eliminating the need for a second input object. Input properties may be rich object types which may have their own properties. The Action properties can be accessed from the web page via the taglibs. Struts 2 also supports the ActionForm pattern, as well as POJO form objects and POJO Actions. Rich object types, including business or domain objects, can be used as input/output objects. The ModelDriven feature simplifies taglb references to POJO input objects. |
| Expression Language: Struts 1 integrates with JSTL, so it uses the JSTL EL. The EL has basic object graph traversal, but relatively weak collection and indexed property support. | Expression Language: Struts 2 can use JSTL, but the framework also supports a more powerful and flexible expression language called "Object Graph Notation Language" (OGNL). |
| Binding values into views: Struts 1 uses the standard JSP mechanism for binding objects into the page context for access. | Binding values into views: Struts 2 uses a "ValueStack" technology so that the taglibs can access values without coupling your view to the object type it is rendering. The ValueStack strategy allows reuse of views across a range of types which may have the same property name but different property types. |
| Type Conversion: Struts 1 ActionForm properties are usually all Strings. Struts 1 uses Commons-Beanutils for type conversion. Converters are per-class, and not configurable per instance. | Type Conversion: Struts 2 uses OGNL for type conversion. The framework includes converters for basic and common object types and primitives. |
| Validation: Struts 1 supports manual validation via a validate method on the ActionForm, or through an extension to the Commons Validator. Classes can have different validation contexts for the same class, but cannot chain to validations on sub-objects. | Validation: Struts 2 supports manual validation via the validate method and the XWork Validation framework. The Xwork Validation Framework supports chaining validation into sub-properties using the validations defined for the properties class type and the validation context. |
| Control of Action Execution: Struts 1 supports separate Request Processors (lifecycles) for each module, but all the Actions in the module must share the same lifecycle. | Control of Action Execution: Struts 2 supports creating different lifecycles on a per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed. |
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
这有帮助吗?
更多类似内容
相关差异对比
探索与 Struts 1 和 Struts 2 相关的类似比较,以获得更广泛的背景和面试准备思路。
浏览比较
从下方查看差异对比
浏览下面所有可用的主题比较,或使用上方搜索框快速缩小范围。
JSF 对比 JSP
阅读结构化的差异与比较指南。
JSP 对比 Servlets
阅读结构化的差异与比较指南。
JSP 对比 ASP
阅读结构化的差异与比较指南。
JSF 1.2 对比 JSF 2.0
阅读结构化的差异与比较指南。
JSF 2.0 对比 JSF 2.1
阅读结构化的差异与比较指南。
Java 5 对比 Java 6
阅读结构化的差异与比较指南。
Java 6 对比 Java 6 update 10
阅读结构化的差异与比较指南。
Java 6 对比 Java 7
阅读结构化的差异与比较指南。
Java 6 update 10 对比 Java 6 update 12
阅读结构化的差异与比较指南。
Java 1.0 对比 Java 1.1
阅读结构化的差异与比较指南。
Java 1.1 对比 Java 1.2
阅读结构化的差异与比较指南。
Java 1.2 对比 Java 1.3
阅读结构化的差异与比较指南。
Java 1.3 对比 Java 1.4
阅读结构化的差异与比较指南。
Java 1.4 对比 Java 5
阅读结构化的差异与比较指南。
Struts 1 对比 Struts 2
阅读结构化的差异与比较指南。
Struts 1.1 对比 Struts 1.2
阅读结构化的差异与比较指南。
Struts 1.2 对比 Struts 1.3
阅读结构化的差异与比较指南。
Linux 对比 Unix
阅读结构化的差异与比较指南。
C 对比 C++
阅读结构化的差异与比较指南。
Java 对比 C++
阅读结构化的差异与比较指南。
Java 对比 J2EE
阅读结构化的差异与比较指南。
Java 对比 Kotlin
阅读结构化的差异与比较指南。
Java 对比 .NET
阅读结构化的差异与比较指南。
Struts 对比 JSF
阅读结构化的差异与比较指南。
Struts 对比 Spring
阅读结构化的差异与比较指南。
Spring 对比 Spring Boot
阅读结构化的差异与比较指南。
Apache 对比 IIS
阅读结构化的差异与比较指南。
Jboss 对比 Tomcat
阅读结构化的差异与比较指南。
Jboss 对比 WebLogic
阅读结构化的差异与比较指南。
WebLogic 对比 Websphere
阅读结构化的差异与比较指南。
JavaScript 对比 Jquery
阅读结构化的差异与比较指南。
JavaScript 对比 VBScript
阅读结构化的差异与比较指南。
JavaScript 对比 TypeScript
阅读结构化的差异与比较指南。
Jquery 对比 AngularJS
阅读结构化的差异与比较指南。
HTML 对比 XML
阅读结构化的差异与比较指南。
HTML 对比 XHTML
阅读结构化的差异与比较指南。
HTML 对比 DHTML
阅读结构化的差异与比较指南。
HTML 5 对比 HTML 4
阅读结构化的差异与比较指南。
Java 7 对比 Java 8
阅读结构化的差异与比较指南。
EJB 2.0 对比 EJB 3.0
阅读结构化的差异与比较指南。
EJB 3.0 对比 Spring
阅读结构化的差异与比较指南。
JDBC 对比 Hibernate
阅读结构化的差异与比较指南。
JDBC 对比 JPA
阅读结构化的差异与比较指南。
JDBC 3.0 对比 JDBC 4.0
阅读结构化的差异与比较指南。
CSS 2 对比 CSS 3
阅读结构化的差异与比较指南。
EJB 1.0 对比 EJB 2.0
阅读结构化的差异与比较指南。
AWT 对比 Swing
阅读结构化的差异与比较指南。
Swing 对比 Applet
阅读结构化的差异与比较指南。
PHP 对比 JSP
阅读结构化的差异与比较指南。
J2EE 对比 J2ME
阅读结构化的差异与比较指南。
Java 8 对比 Java 9
阅读结构化的差异与比较指南。
JPA 对比 Hibernate
阅读结构化的差异与比较指南。
MVC 1 对比 MVC 2
阅读结构化的差异与比较指南。
Hibernate 3 对比 Hibernate 4
阅读结构化的差异与比较指南。
Spring 3.0 对比 Spring 4.0
阅读结构化的差异与比较指南。
Java 9 对比 Java 10
阅读结构化的差异与比较指南。
jQuery Mobile 对比 Bootstrap
阅读结构化的差异与比较指南。
JavaBeans 对比 EJB
阅读结构化的差异与比较指南。
JSON 对比 XML
阅读结构化的差异与比较指南。
RESTful Web Services 对比 SOAP Web Services
阅读结构化的差异与比较指南。
Spring 2.5 对比 Spring 3.0
阅读结构化的差异与比较指南。
HTTP 对比 HTTPS
阅读结构化的差异与比较指南。
AngularJS 对比 NodeJS
阅读结构化的差异与比较指南。
AngularJS 对比 Angular
阅读结构化的差异与比较指南。
NodeJS 对比 Java
阅读结构化的差异与比较指南。
NodeJS 对比 Spring Boot
阅读结构化的差异与比较指南。
NodeJS 对比 Golang
阅读结构化的差异与比较指南。
PaaS 对比 IaaS
阅读结构化的差异与比较指南。
SaaS 对比 PaaS
阅读结构化的差异与比较指南。
SaaS 对比 IaaS
阅读结构化的差异与比较指南。
On-Premise 对比 Cloud Computing
阅读结构化的差异与比较指南。
Monolithic 对比 Microservices
阅读结构化的差异与比较指南。
Java 10 对比 Java 11
阅读结构化的差异与比较指南。
Spring MVC 对比 Spring Boot
阅读结构化的差异与比较指南。
Golang 对比 Java
阅读结构化的差异与比较指南。
Python 对比 Java
阅读结构化的差异与比较指南。
AWS 对比 Azure
阅读结构化的差异与比较指南。
AWS 对比 Google Cloud/GCP
阅读结构化的差异与比较指南。
Ansible 对比 Terraform
阅读结构化的差异与比较指南。
Ansible 对比 Puppet
阅读结构化的差异与比较指南。
Puppet 对比 Terraform
阅读结构化的差异与比较指南。
OpenID Connect 对比 OAuth 2.0
阅读结构化的差异与比较指南。
SAML 对比 OpenID Connect
阅读结构化的差异与比较指南。
Java 11 对比 Java 12
阅读结构化的差异与比较指南。
Java 12 对比 Java 13
阅读结构化的差异与比较指南。
Java 13 对比 Java 14
阅读结构化的差异与比较指南。
Java 14 对比 Java 15
阅读结构化的差异与比较指南。
Java 15 对比 Java 16
阅读结构化的差异与比较指南。
Java 16 对比 Java 17
阅读结构化的差异与比较指南。
Python 2 对比 Python 3
阅读结构化的差异与比较指南。
RDBMS 对比 Hadoop
阅读结构化的差异与比较指南。
Angular 对比 React
阅读结构化的差异与比较指南。
Java 17 对比 Java 18
阅读结构化的差异与比较指南。
GraphQL 对比 RESTful Web Services (REST API)
阅读结构化的差异与比较指南。
RESTful Web Services (REST API) 对比 gRPC
阅读结构化的差异与比较指南。
Android 对比 iOS
阅读结构化的差异与比较指南。
TikTok 对比 Instagram
阅读结构化的差异与比较指南。
Instagram 对比 YouTube
阅读结构化的差异与比较指南。
TensorFlow 对比 PyTorch
阅读结构化的差异与比较指南。
OracleJDK 对比 OpenJDK
阅读结构化的差异与比较指南。