多个表单在J2EE Web应用程序中不起作用

时间:2018-04-01 11:13:25

标签: javascript java html5 css3

我设计了一个包含多个表单的网页,每个表单都提供了唯一的提交按钮,并在提交时定向到不同的servlet。 但是一次只有一个成功提交到数据库,而另一个表单甚至没有被定向到它的servlet。 怎么做?

<!-- UPDATE DONOR CARD-->

    <div class="col-xl-4 " style="opacity:0.9;">
          <div class="card bg-info text-center card-form mb-4">
            <div class="card-body">
              <h3 class="align-center">Update Donors Detail</h3>
              <p>Please fill out this form to update </p>
              <form action="UpdateHospitalController" method="post" name="update">
                <div class="form-group">
                  <input type="text" class="form-control form-control-lg" placeholder="Mobile no." id="mobNo" name="mobNo">
                </div>

                <div class="form-group">
                  <input type="text" class="form-control form-control-lg" placeholder="Date" id="datepickers" name="date">
                </div>


                <input type="submit" class="btn btn-dark btn-block" name="updateSubmit">
              </form>
            </div>
          </div>
        </div>

        <!-- ADD DONOR CARD-->

        <div class="col-xl-4 " style="opacity:0.9;">
          <div class="card bg-info text-center card-form mb-4">
            <div class="card-body">
              <h3 class="align-center">Add Donors</h3>
              <p>Please fill out this form to add </p>
              <form action="HospitalController" method="post" onclick="return(validate())" name="addForm">
                <div class="form-group">
                    <input type="text" class="form-control form-control-lg" placeholder="Mobile no." maxlength="10" id="mobNo" name="mobNos">
                    <span id="sp1"></span>
                </div>
                    <div class="form-group" >
                  <input type="text" class="form-control form-control-lg " placeholder="Name" id="name" name="userName">
                  <span id="sp2"></span>
                </div>
                <div class="form-group">
                    <select class="form-control form-control-lg" placeholder="Blood Group" name="bglist" id="list">


                        <option value="Opos">O+</option>
                        <option value="Oneg">O-</option>
                        <option value="Apos">A+</option>
                        <option value="Aneg">A-</option>
                        <option value="Bpos">B+</option>
                        <option value="Bneg">B-</option>
                        <option value="ABpos">AB+</option>
                        <option value="neg">AB-</option>
                    </select>
                    <span id="sp3"></span>
                </div>

                <div class="form-group" >
                  <input type="text" class="form-control form-control-lg " placeholder="Date" id="datepicker" id="date" name="dates">
                  <span id="sp4"></span>
                </div>
                <div class="form-group">
                  <input type="text" class="form-control form-control-lg" placeholder="City" id="city" name="city">
                  <span id="sp5"></span>
                </div>
                <input type="submit" class="btn btn-dark btn-block" name="addDonor">
              </form>
            </div>
          </div>
        </div>

1 个答案:

答案 0 :(得分:0)

您一次只能在数据库中执行一个查询。您需要使用response.sendRedirect(“filename”)再次将servlet定向到此页面,然后尝试使用其他形式。希望它有所帮助。如果不知道。