zoukankan      html  css  js  c++  java
  • 使用action处理义务请求

    继承Actionsupport类  属性方式接收(字段少时)方法只可以返回string类型

    继承Actionsupport类  方法只可以返回String类型  页面中属性要 对象.属性

    实现 ModelDriven接口  方法可以直接返回任何类型 不需要set 和 get 方法 页面和属性页面一样

    结论:三种Action 接收参数的方式中,当Action 接收非字符串类型参数时,Action 中相
    应属性最好设置为包装类型。

    解决struts.xml文件中多个method对应1个action类造成struts.xm文件过于庞大的方法

    1.使用<inclue>标签按照模块包含多个XML配置文件(按模块在不同的xml文件中配置<action>  使用<inclue>标签包含各个xml文件)

    struts_house.xml:
    <package.........>
                    <action.......>
                    </action>
    </package>
    
    
    
    
    struts.xml:
    <struts>
            .............
            <inclue file="struts_house.xml"/>
    
    </struts>

    2.动态方法调用 (同一个action类中的方法)<不安去容易暴露我们的方法名>请求后面省略了.action
    表单中 <from action= "house!add"  ></form>    name ! 方法名  不需要写Meth方法; 

     3.使用通配符来匹配方法名*  

    设定默认action 但访问不存在的页面是跳转到默认action

    <default-action-ref name="index" />

    <action name="index">

    <result >index.jsp</result>

    </action>

  • 相关阅读:
    NOIP2016 蚯蚓 题解
    BZOJ 1294 围豆豆 题解
    POJ1852 Ants 题解
    BZOJ 1131 [POI2008] STA-Station 题解
    HDU 5963 朋友 题解
    Codeforces 1292C Xenon's Attack on the Gangs 题解
    Emergency Evacuation 题解
    P4408 逃学的小孩 题解
    UVA11300 Spreading the Wealth 题解
    P2882 Face The Right Way G 题解
  • 原文地址:https://www.cnblogs.com/wanghongjie/p/4858158.html
Copyright © 2011-2022 走看看