
Struts 1.x is the most famous, classic and proven Model-View-Contraller (MVC) framework. Often times, you will listen something like, meaningless to learn Struts 1.x, it’s a dead framework. However, with the huge success of Struts 1.x in early day, there are still hundreds of thousand companies are implemented Struts 1.x, and never consider upgrade, so the Struts 1.x is still causing many maintainability.
Struts 1.x is a complete web framework, provides complete web form components, validator, internalization, error handling, tiles layout, low learning curve and easy to implement it. In this tutorials, it provides many step by step examples and explanations on using Struts 1.x MVC framework.
Happy learning Struts. :)
Struts Quick Start
Let’s go through a quick start to understand about the Struts 1.x framework.
- Struts hello world example
Go thought a hello world example to understand how Struts MVC work.
Struts Configuration
All stuffs about Struts configuration.
- Configure the Struts Tag Libraries
To use Struts, you have to configure the Struts tag libraries property, either in manual or automatic way. - Configure a welcome page in Struts
Configure a welcome page in Struts. - Multiple Struts configuration files
Mutiple Struts configuration files are required in large project environment, here’s an example to show how to configure the multiple Struts configuration file. - Struts configuration files in wildcards support
If your project is following certain standard file structure, wildcard is a useful feature to reduce the duplicated code in Struts configuration file.
Struts Action & ActionForm
Action and ActionForm implementation class.
- ForwardAction Example
Allow you to access the JSP class directly, without go through the controller class. - DispatchAction Example
Allow you to group all related functions into a single action class. - MappingDispatchAction Example
Same with DispatchAction, group similar functionality into a single action class but with different mechanism - DynaActionForm example
Allow you to create a virtual form bean declaratively to increase the development speed.
Struts Web Form Components
Struts has complete support for all standard web form components.
- TextBox example
Struts <html:text> textbox example. - Hidden value example
Struts <html:hidden> hidden value example. - Radio option example
Struts <html:radio> radio option example. - Drop down box example
Struts <html:select> drop down box example. - Check box example
Struts <html:checkbox> check box example. - File upload example
Struts <html:file> file upload example. - TextArea example
Struts <html:textarea> textaread example. - Rewrite example
Struts <html:rewrite> example, to render a requested URI, without create the hyperlink, useful for generate JavaScript and CSS file.
Struts Logic Tags
Struts comes with a lot logic tags to ease the bean component iteration or conditional processing.
- <logic:iterate> example
Struts tag to iterate over collections. - <logic:empty> <logic:notEmpty> example
Struts tag to check speficied property is null or zero-length String. - <logic:equal> <logic:notEqual> example
Struts tag to check speficied property is equal to a given value. - <logic:greaterThan> <logic:greaterEqual> <logic:lessThan> <logic:lessEqual> example
Struts conditional tag for comparing numbers. - <logic:match> <logic:notMatch> example
Struts tag to check the speficied property contains the given value as substring. - <logic:messagesPresent> <logic:messagesNotPresent> example
Struts tag to check the speficied message or error message exists on the current request. - <logic:present> <logic:notPresent> example
Struts tag to check the speficied given object or property is exists in the current request.
Struts Error and Logging
Exception handling and error logging.
- <global-exception> custom exception handler
Struts <global-exception> to display the custom error page to user. - Struts + Log4j integration
Integrate Struts with Log4j logging framework to log the system exceptions and errors. - Handle 404 error in Struts
Handling classic 404 error page in Struts.
Struts localization
Struts has good support in internationalizing or localization.
- Struts internationalizing or localization example
A simple user login example, all messages and error messages are localized.
Struts Validator Framework
In Struts validator framework, it provides many generic methods (required, maxlength, minlength..) to validate the form components, it makes your validation code more standardize and easier to maintain.
- Struts validator example
A simple user registration form , and validate the username, password and email field with Struts validator.
Struts Tiles Framework
Struts tiles framework is a powerful layout framework, which is used to maintain a standard look of header, footer or menu details across all of your web pages.
- Struts Tiles framework example
A simple web application to demonstrate the use the Sturts tiles framework to change the header and footer page easily.
Struts Integrate with Other Frameworks
Anything about the Struts integration with others framework.
- Struts + Spring integration
Example to integrate the Struts with Spring framework. - Struts + Hibernate integration
Example to integrate the Struts with Hibernate framework. - Struts + Spring + Hibernate integration
Example to integrate the Struts with Spring and Hibernate framework. - Struts + Quartz scheduler integration
Example to integrate the Struts with Quartz framework. - Struts + Spring + Quartz scheduler integration
Example to integrate the Struts with Spring and Quartz framework.
Struts Misc
Others Struts examples.
- Download file from website example
How to download file from a website in Struts.
Struts Common Errors
Some Struts common error messages.
- The absolute uri: http://struts.apache.org/tags-bean cannot be resolved in either web.xml or the jar files deployed with this application
- java.lang.ClassNotFoundException: org.apache.struts.action.ForwardAction
- Cannot find message resources under key org.apache.struts.action.MESSAGE
- java.lang.NoClassDefFoundError : org/apache/commons/fileupload/FileUploadException
- java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
- <global-exceptions> xml parsing exception
- NoSuchMethodError : Digester.parse(Ljava/net/URL;)Ljava/lang/Object