复选框请求返回null

时间:2017-10-24 09:04:13

标签: java html

复选框请求返回null但我不明白为什么。我认为一切都是正确的...... name正在发挥作用。

JAVA:

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

  //Fetch the data from the GeneralSetup Page
  String name = request.getParameter("name");
  Boolean hasProfile7 = "on".equalsIgnoreCase(request.getParameter("hasProfile7"));
  Boolean hasWebCSR = "on".equalsIgnoreCase(request.getParameter("hasWebCSR"));
  Boolean hasWebAdmin = "on".equalsIgnoreCase(request.getParameter("hasWebAdmin"));
  Boolean hasWebClient = "on".equalsIgnoreCase(request.getParameter("hasWebClient"));

HTML:



<form role="form" method="post" action="GeneralSetup" data-toggle="validator">
  <div class="panel-body">
    <div class="row">
      <div class="col-lg-6">
        <div class="form-group">
          <label for="environmentName" class="form-control-label"><strong>Environment
                                                Name</strong></label>
          <input class="form-control" name="name" id="environmentName" placeholder="Enter the environment name" data-error="Please, insert a valid name"
            required>
          <div class="help-block with-errors"></div>
        </div>
        <div class="form-group">
          <div class="panel panel-blue">
            <div class="panel-heading">
              Deploy Apps
            </div>
            <div class="panel-body">
              <div class="form-group">
                <div class="checkbox">
                  <label>
                    <input type="checkbox" id="profile7" name="hasProfile7" checked disabled required> Profile 7
                  </label>
                </div>
                <div class="checkbox">
                  <label>
                    <input type="checkbox" value="" id="webCSR" name="hasWebCSR"> Web CSR
                  </label>
                </div>
                <div class="checkbox">
                  <label>
                    <input type="checkbox" value="" id="webAdmin" name="hasWebAdmin"> Web Admin
                  </label>
                </div>
                <div class="checkbox">
                  <label>
                    <input type="checkbox" value="" id="webClient" name="hasWebClient"> Web Client
                  </label>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</form>
&#13;
&#13;
&#13;

编辑:

但是这个复选框(在同一页面中)有效:

<div class="form-group">
  <div class="checkbox">
    <label>
      <input type="checkbox" value="Admin" name="user" data-error="Please, choose at least one user" required> Admin</label>
  </div>
  <div class="help-block with-errors"></div>
</div>

0 个答案:

没有答案