struts2 入门

下载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

转载于:https://www.cnblogs.com/nami/archive/2013/04/11/2675335.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值