A Download Struts2.0.1http://struts.apache.org/ downloads.html, download Struts-2.0.1-all.zip, which contains the Struts2-core.jar core packages needed to develop struts2 and other struts2-dependent jar files, plus some struts2 sample programs and some The HTML API documentation. two. Try Struts2.0.1 1. Create a new Web project that will struts-2.0.1-all.zip all jar files in the Lib directory in the compressed package to the/web-inf/of the WEB projectthe Lib directory. Modify Web-inf for the Web. xml file, add the following:<filter> <filter-name>struts2</filter-name> <filter-class>Org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pat Tern>/*</url-pattern> </filter-mapping> <!--here is the setting of the struts2 tag, or not set, because in the Struts-core.jar Meta-inf directory already contains the This TLD file, the Java EE container will automatically load it--<jsp-config> <taglib> <taglib-uri>/s</taglib-uri > <taglib-location>/web-inf/tlds/struts-tags.tld </taglib-location> </taglib> </jsp-config> A struts2 filterdispathcer filter is defined in Web. XML, which is used to initialize STRUTS2 and process all Web requests. 2. Create a new Login page login.jsp:<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%><% @taglib prefix=" s "uri="/struts-tags "%>http://struts.apache.org/dtds/struts-2.0.dtd "><struts> <package name=" struts2 "extends=" Struts-default "> <action name=" Login "class=" ORG.R Ainlife.struts2.action.LoginAction "> <result name=" error ">/error.jsp</result> <res Ult name= "Success" >/success.jsp</result> </action> </package></struts> in this Stru Ts.xml configuration file, you can see that the previous struts-config.xml is completely different, and the configuration file in WebWork is very similar. Here, we define an action named name= "Login", which points to the Loginaction class we just created by using the class attribute, so that the action we define is told to Struts2. In the html/jsp page, the "login" name can be used to submit the action to the corresponding action. If the namespace attribute is set in the package, such as namespace= "/struts2", the action of the form should be set to "/struts2/login.action" in the JSP page. 5. Create error.jsp and success.jsp:error.jsp<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>< html>
Eclipse builds the struts framework, and a simple struts example