Introduction to the Java Struts Framework and tutorial on environment configuration _java

Source: Internet
Author: User
Tags java web apache tomcat java se

Struts2 is a popular and sophisticated Web application framework based on the MVC design pattern. Struts2 is not just Struts1 the next version, it is a fully rewritten struts architecture.

The WebWork framework begins with the struts framework, and its goal is to provide a developer who strengthens and improves the framework struts to make web development easier.

After a while, the webwork framework and the struts community teamed up to build the famous STRUTS2 framework.

Features of the Struts 2 framework:
Here are some powerful features that may force you to consider STRUTS2:

Pojo forms and Pojo actions-the STRUTS2 struts framework has been freed from the Action form component, STRUTS2 can be entered in any Pojo received form. You can also now see any pojo as an action class.

    • Tag Support-STRUTS2 increases the form label and the new label allows developers to write less code.
    • Ajax support-STRUTS2 has been identified by the WEB2.0 technology takeover and integrated into the product by creating Ajax tags that feature very similar standard STRUTS2 tag AJAX support.
    • Easy to integrate-STRUTS2 integrates various integrations with other frameworks such as Spring,tiles and Sitemesh are now easier.
    • Template support-Supports build usage templates.
    • Plug-in support-improves core STRUTS2 features and enhances the use of plug-ins. A large number of plug-ins are available for Struts2.
    • Performance analysis-STRUTS2 analysis, debugging and analysis applications provide integration. In addition, struts provides integrated built-in debugging tool debugging.

Easy to modify tag-Struts2 label annotation, you can adjust the use of Freemarker template. This does not require JSP or Java knowledge. Basic Html,xml and CSS knowledge is enough to modify the label.

Advocate less configuration-Struts2 facilitates fewer configurations with the help of using default settings of various values. Do not have to configure anything unless it does not conform to the STRUTS2 default settings.

View technology:-STRUTS2 has a large support for multiple view options (JSP, Freemarker, Velocity, and XSLT)

These are just the top ten features of Struts2, which makes it a corporate-level application framework.

STRUTS2 Environment Configuration

Our first priority is to have the minimum Struts2 application run. This chapter will guide you in preparing your development environment to start using STRUTS2. I assume that you have installed JDK (5 +), Tomcat and Eclipse on the machine. If you have not installed these components (software), then follow these steps:

Step 1-Install the Java Development Kit (JDK):
from Oracle's Java Web site: Java SE Downloads, you can download the latest version of the SDK. You will find the files downloaded in the installation JDK, and install and configure the settings according to the instructions given. Finally, set the path and JAVA_HOME environment variable to refer to the directory containing Javac and Java, usually: Java_install_dir/bin and Java_install_dir

If you are using Windows, the SDK is installed in c:jdk1.5.0_20, in the file c:autoexec. In the bat file, write the following line.

Set path=c:jdk1.5.0_20 in;%path%
set java_home=c:jdk1.5.0_20

Also, on Windows NT/2000/XP, you can right-click My Computer, select Properties, and then advanced to find environment variables. Then, update the path value (the directory where the JDK is installed) and press the OK button.

On UNIX (Solaris, Linux, etc.), if the SDK is installed in/usr/local/jdk1.5.0_20, using the C shell, you put the following to. cshrc file.

Setenv path/usr/local/jdk1.5.0_20/bin: $PATH
setenv java_home/usr/local/jdk1.5.0_20

Also, if you are using Jbuilder,eclipse,intellij idea, such as Borland, or the Integrated development environment (IDE) of Sun One studio, compile and run a simple program to verify that Java is installed.
Note: Can be developed directly using MyEclipse.

Step 2-apache Tomcat Installation:
You can download the latest version of tomcat:http://tomcat.apache.org/. Once the download is installed, unzip the binary distribution to a convenient location. For example, on Windows can be C:APACHETOMCA, or/usr/local/apache-tomcat-6.0.33 in Linux/unix, and create catalina_home environment variables to point to these locations.

Tomcat can either start the following command on the Windows machine, or you can simply double-click the Startup.bat

 %catalina_home% Instartup.bat


Or

 c:apache-tomcat-6.0.33 Instartup.bat

Tomcat can start the following command on a UNIX (solaris,linux, etc.) machine:

$CATALINA _home/bin/startup.sh


Or

/usr/local/apache-tomcat-6.0.33/bin/startup.sh

After successful startup, the default Web application contained in Tomcat will be accessed by http://localhost:8080/. If all goes well, then it should show the following results:

Further tomcat configuration and running information in the documentation can be found here as well as on the Tomcat site: http://tomcat.apache.org

Stop Tomcat can execute the following command from the Windows machine:

%catalina_home% Inshutdown

Or

c:apache-tomcat-5.5.29 Inshutdown

Stop Tomcat the machine that can execute the following command (Solaris,linux, etc.) on Unix:

$CATALINA _home/bin/shutdown.sh

Or

/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh

Step 3-Install Eclipse (IDE)
all the examples in this tutorial have been written using the Eclipse IDE. So I suggest installing the latest version of Eclipse on the machine.

Install eclipse download Http://www.eclipse.org/downloads the latest eclipse binaries. Once the download is installed, unzip the binary distribution to a convenient location. For example, in Windows for C:eclipse, or/usr/local/eclipse on Linux/unix, the PATH variable is finally set.

Eclipse can start the following command on a Windows machine, or you can simply double-click the Eclipse.exe

 %c:eclipseeclipse.exe

In Eclipse, you can start the following command on a machine on UNIX (Solaris,linux, etc.):

$/usr/local/eclipse/eclipse

After successful startup, if everything works, it should show the following results:

Step 4-Set up the STRUTS2 library
now, if everything works, then you can set the STRUTS2 framework. Here are the simple steps to download and install the STRUTS2 on the machine.

Make a choice whether you want to install STRUTS2 in Windows or UNIX, and then proceed to the next step. zip file download in Windows,.tz for UNIX files.

Download the latest version of the STRUTS2 binaries http://struts.apache.org/download.cgi.

When I wrote this tutorial, I downloaded the struts-2.0.14-all.zip to unzip the downloaded file, c:struts-2.2.3 like the directory structure.

The second step is to extract any location in the zip file, I download and decompress struts-2.2.3-all.zip in the C: folder, all jar files on the Windows 7 machine are placed into the C:struts-2.2.3lib directory. Be sure to set the CLASSPATH variable correctly, otherwise the problem will arise when the application runs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.