如何使用html和java servlet创建动态表?

时间:2016-07-17 15:59:41

标签: java html mysql servlets

我有一个存储税务信息的mysql表。这是它的外观。 enter image description here

目前我正在使用html / servlet来显示表格,但效果非常无效,如下图所示。

enter image description here

查看税务信息显示mysql表中有值时的表格,如下所示:

enter image description here

如果用户希望对其进行编辑,则必须单击“编辑纳税信息”按钮,该按钮会显示以下内容:

enter image description here

有没有一种有效的方法来完成所有这些功能?就像这样:

enter image description here

示例代码:

HTML:

<?php

if (isset($_POST['submit_form'])) {

    $file = preg_replace("/[^0-9a-z.\-_ ]/i", "", $_POST['file']);
    $file_path =  'download/'. $file . '.zip';

    if (file_exists($file_path)) {

        header('Content-Disposition: attachement; filename=' . basename($file_path));
        header('Content-Type: application/force-download');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Content-Length: ' . filesize($file));
        header('Connection: close');
        readfile($file);
    }
    else { echo "File not found"; exit; }
} 
?>

<form action="" method="post">
    <input type="text" name="file" placeholder="Enter filename here" />
    <input type="submit" name="submit_form" value="Download starten" />
</form>

的Servlet

<div id="container">
<h1>Add Tax Bracket</h1>
<form action ="AddTax" method = "post"> 


    <table border ="1"> 

    <tr>
    <td>Tax Bracket</td>
    <td><input type = "number" name = "bracket" min="0" step="1"  required></td>
    </tr>

    <tr>
    <td>From Salary($)</td>
    <td><input type = "number" name = "FromSalary" min="0" step="0.01"  required></td>
    </tr>

    <tr>
    <td>To Salary($)</td>
    <td><input type = "number" name = "ToSalary" min="0" step="0.01"  required></td>
    </tr>

    <tr>
    <td>Tax Rate(%)</td>
    <td><input type = "number" name = "rate" min="0" step="0.01"  required></td>
    </tr>

    </table>
    <br>
    <br>
    <input type = "submit" value = "Add Tax Bracket">
    </form>

    <h1>Remove Tax Bracket</h1>

    <form action ="RemoveTax" method = "post"> 
    <table border ="1"> 

    <tr>
    <td>Tax Bracket to remove</td>
    <td><input type = "number" name = "bracket1" min="0" step="1"  required></td>
    </tr>
    </table>
    <br>
    <br>
    <input type = "submit" value = "Remove Tax Bracket">
    </form>

    </div>
</body>

</html>

0 个答案:

没有答案