从jsp中的表单中获取数据

时间:2016-02-22 07:22:24

标签: java forms jsp

我的jsp中有一个表单,没有固定数量的字段。用户可以根据需要添加行数。这是我的表格代码:

<form class="metrics_values"  action="refreshMetrics.jsp" method="POST">
   <div id="userId">User test id: <input type="text" name="userId" /> <input class="none" type="submit" value="Submit"></div>

            <div class="rowWrapper">
                <div class="row mName">
                    <input list="metrics" placeholder="Metric Name" name="metric_name" />
                    <datalist id="metrics">
                        <option value="userAgent">
                        <option value="header">
                        <option value="sni">
                        <option value="isversion_1_1">
                        <option value="sslVersion">
                        <option value="contenttype">
                        <option value="days">
                        <option value="server">
                        <option value="expip">
                        <option value="expauth">
                        <option value="expectmatch">
                        <option value="username">
                        <option value="password">
                        <option value="dbname">
                        <option value="redirectionFlag">
                        <option value="noDnsCache">
                        <option value="redirectionFlag">
                    </datalist>
                </div>  
        <div class="row mvalue">
                     <input type="text" placeholder="Metric Value" name="metric_value" />
                </div>
            </div>            
    </form>     
    <a href="#" title="add row" class="add-row">+</a>

用于添加行的jQuery:

 jQuery(function(){
      var counter = 1;
      jQuery('a.add-row').click(function(event){
        event.preventDefault();
        counter++;
        var newRow = jQuery('<div class="rowWrapper"><div class="row mName"> <input list="metrics" placeholder="Metric Name" name="metric_name"/> </div><div class="row mvalue"><input type="text" placeholder="Metric Value" name="metric_val"/></div></div>');
        jQuery('form.metrics_values').append(newRow);
      });
     });

我试图用这个来获取数据:

     Enumeration<String> paramNames = request.getParameterNames();
            while (paramNames.hasMoreElements()) {
                String paramName = (String) paramNames.nextElement();
                out.print("<tr><td>" + paramName + "</td>\n");
                String paramValue = request.getHeader(paramName);
                out.println("<td> " + paramValue + "</td></tr>\n");
            }

但它会为null返回paramValue

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

试试这个:

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];

    UITouch *touch = [touches anyObject];

    CGFloat maximumPossibleForce = touch.maximumPossibleForce;
    CGFloat force = touch.force;

    NSLog(@"***** force value : %f", force);

    CGFloat normalizedForce = force/maximumPossibleForce;

    NSLog(@"Normalized force : %f", normalizedForce);

    if (normalizedForce > 0.75)
    {
        // Pop
    }
    else if (normalizedForce > 0.20)
    {
        // Peek
    }
}