zoukankan      html  css  js  c++  java
  • 一个form中对应多个动作

    如果想要给一个form表单赋予多种操作。如:

    在这个表单中,希望可以有“删除”和“移动”两种动作。但是一个form只有一个action处理

    要怎样才能用一个action应对两种不同的操作呢?

    在servlet的参数HttpServletRequest req中,有一个函数,名为getParameterNames()。

    这个参数的含义是:

    Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.
    Returns:
    an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

    也就是说它可以返回request对象里面的所有参数的名字。

    这样一来,我们可以通过赋予不同的按钮以不同的名字来区分我们点击的是哪个操作。

    如:

    在servlet中打印输出getParameterNames()函数返回的数组,可以看到:

    当我们点击“删除”按钮时,输出的内容是:

    当我们点击“移动”按钮时,输出的内容是:

    也就是说各个操作只会出现一个,因此只要进行逻辑判断就可以知道选择的那些checkbox是希望进行什么操作的了。

  • 相关阅读:
    00-深入理解C#读书笔记说明
    00-翻译IdentityServer4的目的
    IdentityServer4-介绍大纲(译文)
    (CLR-Via-C#) 类型基础
    委托
    字符串匹配算法
    weight_decay(权重衰减)
    文本主题模型--LDA
    词义消歧
    模型融合的结合策略
  • 原文地址:https://www.cnblogs.com/elaron/p/2719635.html
Copyright © 2011-2022 走看看