Struts2默认配置

Struts2默认配置


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
        <!-- 
            package: 包. struts2 使用 package 组织模块.
            name 属性: 必须. 用于其他的包应用当前包
            extends: 当前继承哪个包, 继承的, 即可以继承其中的所以配置, 通常情况下继承 struts-default
         -->
    <package name="helloworld" extends="struts-default">
        <!--
              配置一个action, 一个struts2的请求就是一个action 
             name: 对应一个 struts2 的请求的名字, 不包含扩展名
             class 的默认值 com.opensymphony.xwork2.ActionSupport
             method 的默认值 execute
             name 的默认值是 success
             result: 结果.     
        -->
        <action name="product-input"
                class="com.opensymphony.xwork2.ActionSupport"
                method="execute">
                <!-- 
                    result: 结果. 表示action 方法执行后可能返回的一个结果. 所以一个 action 节点可能会有多个 result 子节点
                    多个子节点 使用 name 来进行区分
                    name: 标识一个result. 和 action 的返回值对应  默认值为 success
                    type: 返回的结果类型 默认是 dispatcher 转发
                 -->
            <result name="success" type="dispatcher">/WEB-INF/pages/input.jsp</result>
        </action>

        <action name="product-save" class="com.xieth.structs2.helloworld.Product"
            method="save">
            <result name="details">/WEB-INF/pages/details.jsp</result>
        </action>

    </package>
</struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <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>

</web-app>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值