请求有效按钮状态

时间:2017-08-10 10:18:26

标签: jquery twitter-bootstrap spring-mvc

我将Bootstrap与Spring Boot / MVC和thymeleaf结合使用

目前我有一个按钮,可以被用户按下并标记为有效。

但我的问题是,我无法在后端收到该按钮的状态。

例如,如果我使用复选框功能,我可以通过

获取状态
  <td><label class="checkbox-inline"><input type="checkbox" value="true" name="checkboxvalue"/></label></td>

通过这种方式访问​​状态:

    httpEntity.getBody().contains("checkboxvalue")

现在主动按钮部分是我的问题

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:replace="template :: head">
</head>
<body>

<div class="container">
    <form method="post" action="specifyDetails">
        <h2>Chose what you want to trade</h2>
        <label>
            <select th:name="Products" class="selectpicker" multiple="multiple">
                <!--/*@thymesVar id="productList" type="java.util.List"*/-->
                <option th:each="product : ${productList}"><a th:text="${product}"></a></option>
            </select>
        </label>
        <button th:type="submit" class="btn btn-info">Send</button>
    </form>
    <form><a th:href="'orderview/'" href="#" class="btn btn-default btn-sm" role="button">Orderview only</a>
    </form>
<input th:type="button" id="activeButton" name="basketOrders" class="btn btn-info" value="true"/>


<div th:replace="template :: footer"></div>
</body>
</html>

这里是 template.html

   <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:th="http://www.thymeleaf.org">
    <head th:fragment="head">
        <meta charset="UTF-8"/>
        <!--/*@thymesVar id="title" type="String"*/-->
        <title th:text="${title}">Library trader</title>
    </head>

   <footer th:fragment="footer">
    <script th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
    <script th:src="@{/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js}"></script>
    <script th:src="@{/webjars/bootstrap-select/1.12.2/js/bootstrap-select.min.js}"></script>
    <script>$('#activeButton').click(function (e) {
        e.preventDefault();
        $(this).addClass('active');
    })</script>


    <link th:href="@{/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/webjars/bootstrap/3.3.7-1/css/bootstrap-theme.min.css}" rel="stylesheet"/>
    <link th:href="@{/webjars/bootstrap-select/1.12.2/css/bootstrap-select.min.css}" rel="stylesheet"/>
</footer>

当我现在调用httpEntity.getBody()时,无论按钮是否被按下,我都无法获得有关该按钮的任何信息......

所以请告诉我,我如何能够访问按钮的状态。非常感谢你。

0 个答案:

没有答案
相关问题