Centralized File-Based Configuration.
Rather than hard-coding information into Java programs, many Struts values are represented in XML or property files. This loose coupling means that many changes can be made without modifying or recompiling Java code, and that wholesale changes can be made by editing a single file.
Form Beans.
In JSP, you can use property="*"
with jsp:setProperty
to automatically populate a JavaBean component based on incoming request parameters.
Bean Tags.
Apache Struts provides a set of custom JSP tags (bean:write
, in particular) that let you easily output the properties of JavaBeans components. Basically, these are concise and powerful variations of the standard jsp:useBean
and jsp:getProperty
tags.
HTML Tags.
Apache Struts provides a set of custom JSP tags to create HTML forms that are associated with JavaBeans components. This bean/form association serves two useful purposes:
- It lets you get initial form-field values from Java objects.
- It lets you redisplay forms with some or all previously entered values intact.
Form Field Validation.
Apache Struts has builtin capabilities for checking that form values are in the required format. If values are missing or in an improper format, the form can be automatically redisplayed with error messages and with the previously entered values maintained.
This validation can be performed on the server (in Java), or both on the server and on the client (in JavaScript).
Consistent Approach.
Struts encourages consistent use of MVC throughout your application.
Easy to learn and implement
Struts makes it easier to develop large web apps
Large user base
The dominant (by far) framework - developers available, advice
available, books, etc
Open Source.
Open source, freely usable
All components subclassable or replaceable!
Includes powerful JSP Tag libraries
Supported by third-party packages
With a controller, a Web application is a series of requests and
responses, as HTTP intended. The views request and an action responds
with another view. Ideally, your views become scriplet-free "JavaBean
Pages", that could be easily edited with a visual Java 2 Web editor (at
least as soon as we get one!).
· Less Transparent.
With Struts applications, there is a lot more going on behind the scenes than with normal Java-based Web applications. As a result, Struts applications are:
- Harder to understand
- Harder to benchmark and optimize
· Rigid Approach.
The flip side of the benefit that Struts encourages a consistent approach to MVC is that Struts makes it difficult (but by no means impossible) to use other approaches.
Sometimes MVC is not needed. It depends on what your application is, how many people you will have working on it, and most importantly what the skill level is of the people coding your application.
You might be better off with PHP or just scriptlets rather that dealing with all of the theoretical benefits of MVC.
No comments:
Post a Comment