struts中的一些常用配置

来源:互联网 发布:楼房平面图设计软件 编辑:程序博客网 时间:2024/06/11 13:35
<?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>
    <!-- 添加struts2请求后缀常量 -->
    <!-- <constant name="struts.action.extension" value="action,do"></constant> -->
     <!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false -->
    <constant name="struts.configuration.xml.reload" value="true"/>
    <!-- 打开动态方法调用 -->
    <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
    
    <package name="user" namespace="/" extends="struts-default">
        <!-- 测试动态方法调用 -->
        <action name="HelloAction" class="com.action.HelloAction">
            <result name="success">/index.jsp</result>
            <result name="success2">/index.jsp</result>
            <result name="success3">/index.jsp</result>
        </action>


        <!-- 测试通配符配置-->
        <action name="HelloAction_*" class="com.action.HelloAction" method="{1}">
            <result name="success">/index.jsp</result>
            <result name="success2">/index.jsp</result>
            <result name="success3">/index.jsp</result>
        </action>
    
    </package>

</struts>



<?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>
    <!-- 添加struts2请求后缀常量 -->
    <constant name="struts.action.extension" value="action,do"></constant>
     <!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false -->
    <constant name="struts.configuration.xml.reload" value="true"/>
        
    <!-- localhost:8080/struts2_20170906/test/HelloAction.action -->
    <!-- name:必填,保证唯一,名称任意(通常使用模块名称) namespace:可选,如果有值,就需要在请求地址中添加 extends:必填,只有继承了struts-default,才能使用struts2的功能 -->
    <package name="user" namespace="/" extends="struts-default">
        <!-- name:必填,保证唯一,名称通常使用控制器类的名称 class:控制器的路径 method:控制器的方法 -->
        <action name="HelloAction" class="com.action.HelloAction"
            method="execute">
            <!-- name:控制器中方法的返回字符串 -->
            <result name="success">/index.jsp</result>
        </action>

        <action name="HelloAction2">
            <result>/index.jsp</result>
        </action>

        <!---------------------------------------- dispatcher(默认值):转发到jsp chain:转发到action redirect:重定向到jsp redirectAction:重定向到action -->
        <action name="HelloAction3" class="com.action.HelloAction"
            method="execute">
            <result name="success" type="dispatcher">/index.jsp</result>
        </action>
        
        <action name="HelloAction4" class="com.action.HelloAction"
            method="execute">
            <result name="success" type="chain">HelloAction</result>
        </action>
        
        <action name="HelloAction5" class="com.action.HelloAction"
            method="execute">
        </action>
        
        <action name="HelloAction6" class="com.action.HelloAction"
            method="execute">
            <result name="success" type="redirectAction">
                <param name="actionName">HelloAction</param>
            </result>
        </action>

    </package>
</struts>



原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 捡到一颗子弹该怎么办 防弹衣只保护身体那手臂怎么办? 被子被宝宝尿湿怎么办 眼睛被子弹打了怎么办 gta5买了2套衣服怎么办 gta5车被摧毁了怎么办 gta5车被损坏了怎么办 头盔玻璃磨花了怎么办 浇花喷水壶坏了怎么办 电力专用光缆撞了怎么办 国防电缆挖断了怎么办 国防光缆挖断了怎么办 房门前乱挂光纤线影响住户怎么办 挂断低于限高的光缆怎么办 开大车挂住光缆怎么办 风把树枝挂断压到车该怎么办 货车柴油冻住了怎么办 尖头鞋老是折尖怎么办 打 氟氯西林疼怎么办 多余的十字绣线怎么办 硅胶类的东西沾到蓝药水怎么办? ph计斜率不到90怎么办 ph计斜率低于90怎么办 顾客说衣服起球怎么办 买的手机壳太滑怎么办 硅胶手机壳太滑怎么办 磨砂手机壳太滑怎么办 被热胶棒烫了怎么办 车钢垫子次了怎么办 【图】机组主轴密封漏水怎么办? 孕妇吃了好多杏怎么办 怀孕6个月吃了好多杏怎么办 白色纯棉衣服染色了怎么办 红色硅胶壳黑了怎么办 小米6gps信号弱怎么办 网线头卡子断了怎么办 入户网线太短了怎么办 孩子弹钢琴大拇指出琴键怎么办 手指肿胀疼痛变粗怎么办 iphone系统占用内存大怎么办 手机系统占用内存大怎么办