Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > struts中action的通过传过来的参数判断跳转的两种方法
【标  题】:struts中action的通过传过来的参数判断跳转的两种方法
【关键字】:struts,action
【来  源】:http://blog.csdn.net/yjboy1982/archive/2006/10/13/1333317.aspx

struts中action的通过传过来的参数判断跳转的两种方法

Your Ad Here

struts中action的通过传过来的参数判断跳转的两种方法

我原来用的方法:
struts-config.xml
    <action name="legalAidForm" path="/legalaid/legalAidSeAction" scope="session" type="sms.legalaid.LegalAidSeAction" validate="false">
      <forward name="legalAid.select_1.success" path="/legalaid/selectOneIndex1.jsp"/>
      <forward name="legalAid.select_1.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_2.success" path="/legalaid/selectOneIndex2.jsp"/>
      <forward name="legalAid.select_2.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_3.success" path="/legalaid/selectOneIndex3.jsp"/>
      <forward name="legalAid.select_3.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_4.success" path="/legalaid/selectIndex.jsp"/>
      <forward name="legalAid.select_4.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_5.success" path="/legalaid/selectone.jsp"/>
      <forward name="legalAid.select_5.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_6.success" path="/legalaid/legalAidindex.jsp"/>
      <forward name="legalAid.select_6.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.previouspage.success" path="/legalaid/fy.jsp"/>
      <forward name="legalAid.previouspage.fail" path="/legalaid/fail.jsp"/>
    </action>

传入参数的jsp
<html:link page="/legalaid/legalAidSeAction.do?action=select6">网站首页测试
</html:link>

判断的Action

        String action = request.getParameter("action");
        if (action.equalsIgnoreCase("select6")) {
            allList = bean.select_6();
            rowSetPage = new RowSetPage(allList, 6);
            pageList = rowSetPage.getPageList();
            if (pageList != null) {
                session.setAttribute("pageList6", pageList);
                session.setAttribute("page", rowSetPage);
                return mapping.findForward("legalAid.select_6.success");
            } else {
                return mapping.findForward("legalAid.select_6.fail");
            }
        }

现在的方法是在struts-config.xml中的<action>中增加一个参数parameter="action"
struts-config.xml

    <action name="legalAidForm" parameter="action" path="/legalaid/legalAidSeAction" scope="session" type="sms.legalaid.LegalAidSeAction" validate="false">
      <forward name="legalAid.select_1.success" path="/legalaid/selectOneIndex1.jsp"/>
      <forward name="legalAid.select_1.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_2.success" path="/legalaid/selectOneIndex2.jsp"/>
      <forward name="legalAid.select_2.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_3.success" path="/legalaid/selectOneIndex3.jsp"/>
      <forward name="legalAid.select_3.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_4.success" path="/legalaid/selectIndex.jsp"/>
      <forward name="legalAid.select_4.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_5.success" path="/legalaid/selectone.jsp"/>
      <forward name="legalAid.select_5.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.select_6.success" path="/legalaid/legalAidindex.jsp"/>
      <forward name="legalAid.select_6.fail" path="/legalaid/fail.jsp"/>
      <forward name="legalAid.previouspage.success" path="/legalaid/fy.jsp"/>
      <forward name="legalAid.previouspage.fail" path="/legalaid/fail.jsp"/>
    </action>

传入参数的JSP还是没有变

判断的Action中去掉从session中取值,去掉判断,方法的名字就是action的参数值

     public ActionForward index1(ActionMapping mapping, ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response) {

            allList = bean.select6();
            rowSetPage = new RowSetPage(allList, 6);
            pageList = rowSetPage.getPageList();
            if (pageList != null) {
                session.setAttribute("pageList6", pageList);
                session.setAttribute("page", rowSetPage);
                return mapping.findForward("legalAid.select_6.success");
            } else {
                return mapping.findForward("legalAid.select_6.fail");
            }
        }
 

 

两种方法都可以实现Action页面跳转,后一种方法怪怪的,创建了方法,但是,没有调用这个方法啊?谁来调用呢?

还是有点不明白

数据库中锁机制的学习:【上一篇】
Java数据报(UDP)编程:【下一篇】
【相关文章】
  • struts最常用的数据应用
  • 采用struts+hibernate+spring开发的一个web系统(6)
  • 采用struts+hibernate+spring开发的一个web系统,源代码下载申明
  • 采用struts+hibernate+spring开发的一个web系统 正式提供下载
  • 采用struts+hibernate+spring开发的一个web系统(4)
  • 采用struts+hibernate+spring开发的一个web系统(5)
  • struts+hibernate
  • Struts开发资源合集
  • Struts快速开发
  • [译] JavaServer Faces in Action 中关于 action listener 的讲解部分
  • 【随机文章】
  • HDL逻辑综合软件
  • VB中读取目录路径的方法两则
  • Linux IPC 参数设定
  • 数据库设计范式
  • emf&gef之三nodenew
  • 用三天调了个死锁问题
  • 仙境传说RO 超魔导士技能探讨
  • Word 2000排版教你四招
  • linux系统设定常用指令
  • Win系统之九大常用密码--用户密码
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.