我是 JSP 的新手。我正在创建一个显示通知批准的表。它的功能是显示管理员是否批准记录。但是,当我单击“接受”按钮时,没有任何变化(页面和数据库都保持为 0)。我的代码有错误吗??请帮忙。先感谢您。
我的 JSP 文件中的 Javascript:
<script language="JavaScript">
function submitaccept(){
String connectionURL = "jdbc:mysql://localhost/ams";
Connection connection =null;
PreparedStatement pstatement = null;
var sqlstr = "UPDATE notification SET ack_flag = 1 WHERE notification_id = 001;";
connection = DriverManager.getConnection(connectionURL, "root", "");
pstatement =connection.prepareStatement(sqlstr);
pstatement.executeUpdate();
location.reload(true);
}
我的JSP文件的调用函数:
<c:choose>
<c:when test="${row.ack_flag=='0'}">
<a href="javascript:submitaccept()" >
Approve</a> |
<a href="notification.jsp" >
Reject </a>
</c:when>
<c:when test="${row.ack_flag=='1'}">
Approved
</c:when>
<c:otherwise>
Rejected
</c:otherwise>
</c:choose>