Javascript 获取表的参数? “parameterName=parameterValue”, 函数(responseStatus、responseText){ makeTable(responseStatus,JSON.parse(responseText); } ); } } //textarea单元格的格式化程序 var textAreaCellFormatter=void 0; { textAreaCellFormatter=函数(rowId){ 返回“” +罗维德 + ''; } } //按钮单元格的格式化程序 var buttoncellformatter=void 0; { buttonsCellFormatter=函数(rowId){ 返回“” +“保存” + '' + '' +“删除” + ''; } } //建造你的桌子 var makeTable=void 0; { makeTable=函数(状态,jsonResponse){ var table=document.getElementById(“eeMsg”); //如果表内容已加载,请删除它 对于(变量i=1;i

Javascript 获取表的参数? “parameterName=parameterValue”, 函数(responseStatus、responseText){ makeTable(responseStatus,JSON.parse(responseText); } ); } } //textarea单元格的格式化程序 var textAreaCellFormatter=void 0; { textAreaCellFormatter=函数(rowId){ 返回“” +罗维德 + ''; } } //按钮单元格的格式化程序 var buttoncellformatter=void 0; { buttonsCellFormatter=函数(rowId){ 返回“” +“保存” + '' + '' +“删除” + ''; } } //建造你的桌子 var makeTable=void 0; { makeTable=函数(状态,jsonResponse){ var table=document.getElementById(“eeMsg”); //如果表内容已加载,请删除它 对于(变量i=1;i,javascript,java,mysql,spring,Javascript,Java,Mysql,Spring,Servlet 上述情况也一样 JSP <!-- libs and css --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"> <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-tabl

Servlet

上述情况也一样

JSP

<!-- libs and css -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.js"></script>
<!-- your table in your body, not builded yet -->
<table id="eeMsg"
       data-toolbar="#toolbar"
       data-toggle="table"
       data-pagination="true"
       data-search="true"
       data-url="yourFetchURLWithJSONResponse">
    <thead>
        <tr>
            <th data-field="seq_no">Sortation</th>
            <th data-field="type_big_category">situation</th>
            <th>check</th>
            <th colspan="2">message</th>
        </tr>
    </thead>
</table>

分拣
情况
检查
消息

我看到您使用的是Java,所以很可能您使用的是类似servlet的请求处理器。所以你至少有两种方法来表达你的观点,第三种方法只是我觉得有用的一个建议:

  • 将列表添加为JSP请求的属性,并使用JSTL
  • 使用异步javascript请求(即fetch或XHR)获取列表
  • 使用第三方库(如Boostrap表)
将列表添加为JSP请求的属性,并使用JSTL Servlet

将列表添加到请求属性

public void doGet(//或doPost
HttpServletRequest请求,
HttpServletRes
)抛出ServletException、IOException{
List myList=new ArrayList();
请求setAttribute(“myList”,myList);
}
JSP

<!-- libs and css -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.js"></script>
<!-- your table in your body, not builded yet -->
<table id="eeMsg"
       data-toolbar="#toolbar"
       data-toggle="table"
       data-pagination="true"
       data-search="true"
       data-url="yourFetchURLWithJSONResponse">
    <thead>
        <tr>
            <th data-field="seq_no">Sortation</th>
            <th data-field="type_big_category">situation</th>
            <th>check</th>
            <th colspan="2">message</th>
        </tr>
    </thead>
</table>
使用JSTL遍历列表,并为表中每行的每个单元格调用所需的任何对象属性

$(function() {
    $.ajax({
        url : "/dblistdata",
        type : "GET",
        dataType : "json",
        success : function(result) {
            console.log(result);

            for (var i = 0; i < result.length; i++) {
                var tableBody = "
                    <tr>
                        <td>" + result[i].seq_no + "</td>
                        <td>" + result[i].type_big_category + "</td>
                        <td>
                            <label class="checkbox" for="checkbox01">
                            <input type="checkbox" name="checkbox" id="checkbox01" checked="checked" />
                            </label>
                        </td>
                        <td>
                            <textarea class="form-control push-text">" + result[i].body + "</textarea>
                        </td>
                        <td>
                            <button type="button" class="btn btn-primary">save</button>
                            <button type="button" class="btn btn-default" id="deletebutton">dlete</button>
                        </td>
                    </tr>
                ";

                $('#tbody').append(tableBody);
            }
        }
    })
});

分拣
情况
检查
消息
${object.seq_no}
${object.type\u big\u category}
身体
拯救
删除
但不要忘记JSTL声明


使用异步javascript请求(即fetch或XHR)获取列表 Servlet

将列表添加到请求属性中,但作为JSON格式,可以使用库中的
org.JSON.JSONArray

public void doPost(//或doGet
HttpServletRequest请求,
HttpServletRes
)抛出ServletException、IOException{
List myList=new ArrayList();
JSONArray JSONArray=新JSONArray(myList);
res.setContentType(“应用程序/json”);
res.getWriter().print(jsonArray);
res.getWriter().flush();
res.getWriter().close();
res.flushBuffer();
}
JSP

<!-- libs and css -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.js"></script>
<!-- your table in your body, not builded yet -->
<table id="eeMsg"
       data-toolbar="#toolbar"
       data-toggle="table"
       data-pagination="true"
       data-search="true"
       data-url="yourFetchURLWithJSONResponse">
    <thead>
        <tr>
            <th data-field="seq_no">Sortation</th>
            <th data-field="type_big_category">situation</th>
            <th>check</th>
            <th colspan="2">message</th>
        </tr>
    </thead>
</table>
只有静态HTML,表将使用javascript构建


分拣
情况
检查
消息
Javascript

将您的响应解析为JSON,并迭代以使用构建表

//XHR post函数
var sendXHRPost=void 0;
{
sendXHRPost=函数(url、参数、回调){
var http=new XMLHttpRequest();
http.open('POST',url,true);
http.setRequestHeader('Content-type','application/x-www-form-urlencoded');
http.onreadystatechange=函数(){
如果(http.readyState==4){
回调(http.status,http.responseText);
}
}
http.send(params);
}
}
//获取您的表数据
var fetchTableData=void 0;
{
fetchTableData=函数(){
sendXHRPost(
“我的URL”,
//也许您不传递参数来获取表?
“parameterName=parameterValue”,
功能(响应)
<!-- libs and css -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.2/dist/bootstrap-table.min.js"></script>
<!-- your table in your body, not builded yet -->
<table id="eeMsg"
       data-toolbar="#toolbar"
       data-toggle="table"
       data-pagination="true"
       data-search="true"
       data-url="yourFetchURLWithJSONResponse">
    <thead>
        <tr>
            <th data-field="seq_no">Sortation</th>
            <th data-field="type_big_category">situation</th>
            <th>check</th>
            <th colspan="2">message</th>
        </tr>
    </thead>
</table>