Home > Java > javaTutorial > body text

Struts entry experience (1)

黄舟
Release: 2016-12-17 10:39:39
Original
1340 people have browsed it

Struts installation:
First, please go to http://jakarta.apache.org/Struts to download Struts. It is recommended to use the release version. The highest version now is 1.1. After downloading, you will get a Zip file.
 
 Unzip the ZIP package and you can see this directory: lib and webapps. There are some WAR files under webapps. Assuming that your Tomcat is installed in c:Tomcat, copy those WAR files to C:Tomcatwebapps and restart Tomcat. Open the browser and enter: http://localhost:8080/Struts-example/index.jsp in the address bar. If you can see the dark blue icon of "powered by Struts", it means success. This is an example that comes with Struts, with specific documentation attached, and can be used as an introductory tutorial for beginners. In addition, Struts also provides a system of practical objects: xml processing, automatic processing of JavaBeans properties through java reflection APIs, international prompts and messages, etc.
  
 An example:
 A user registration system, the user enters relevant information through the web page: Registration ID No., password, and EMAIL. If the registration is successful, a success message will be returned. Otherwise, a registration failure message will appear.
 
 The following is part of the core code of the relevant files.
 
 Project establishment:
 Before formal development, this project needs to be established in Tocmat (my tomcat is installed in c:tomcat). A faster way to create it is: create a new directory test under C: tomcatwebapps, then copy the
  
  WEB-INF directory under C: tomcatwebappsstruts-example to the test directory, and then copy the src and classes directories under testWEB-INF Clear it, and clear the contents of the struts-config.xml file. In this way, all the Struts class packages and related configuration files we need are available.
 
When developing, place the JSP files in the test directory, the original Java files in testWEB-INFsrc, and the compiled class files in testWEB-INFclasses.
 
 Registration page: reguser.jsp
 <%@ page contentType="text/Html;charset=UTF-8" language="java" %>
 <%@ taglib uri="/WEB-INF/Struts -bean.tld" prefix="bean" %>
 <%@ taglib uri="/WEB-INF/Struts-html.tld" prefix="html" %>
 
 
  RegUser
 
 
 errors/>
  
 


  
  
  
  
   
  
  
  
   
  
  
  
  

   
   

   PassWord:
   

  < ;html:password property="password" size="20" maxlength="20"/>
  

   E-mail:
  

   
  
  

  

   
  

  
   
 This JSP page is different from ordinary JSP pages because it uses a large number of taglibs. These taglibs may be difficult for beginners to master, but this is one of the essences of Struts. Flexible use will greatly improve development efficiency.

The above is the content of Struts entry experience (1). For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template