开发struts2步骤

<1>:新建Webproject
 <2>:导入相应的jar文件
  struts2-core-2.0.11.2.jar
  xwork-2.0.5.jar
  ognl-2.6.11.jar
  freemarker-2.3.8.jar
  commons-logging-1.0.4.jar
 <3>:配置web.xml 配置filter
    <filter>
           <filter-name>struts2</filter-name>
          <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
     </filter>

     <filter-mapping>
         <filter-name>struts2</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
 <4>:开发Action
  1:普通的java类
  2:含有execute方法
  3:execute方法返回值为string
 <5>:配置struts.xml
 <struts>
      <package name="example" extends="struts-default">

       <action name="login" class="cn.com.ambow.struts2.day1.web.action.LoginAction">
       
       <result name="success">/day1/success.jsp</result>
       
       <result name="error">/day1/error.jsp</result>
      </action>
     </package>
 </struts>

 Struts2的后缀名为:action

你可能感兴趣的:(开发struts2步骤)