下载struts2:http://struts.apache.org/2.x/ 

搭建struts2项目

1.导入struts2所需jar包(struts2 jar包说明)

2.编辑Web应用的web.xml配置文件,配置Struts 2的核心Filter。

View Code
<filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

     <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

3.创建struts.xml文件(struts.xml详解1struts.xml详解2)

4.创建Action类,添加execute方法。要继承com.opensymphony.xwork2.ActionSupport 类或者其他已经继承此类的类

5.在struts.xml文件中配置action

View Code
<action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
            <result name="success">/HelloWorld.jsp</result>
        </action>

另外struts的官网提供了很多例子,有空白项目,也有演示功能的demo。

下载struts2例子:http://code.google.com/p/struts2-examples/downloads/list

相关文章:

  • 2021-09-19
  • 2021-10-30
  • 2021-10-03
  • 2021-09-19
  • 2021-08-04
  • 2019-06-16
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2021-11-29
  • 2021-11-06
  • 2022-01-06
  • 2022-12-23
相关资源
相似解决方案