jsp页面表单提交后mysql未更新原因
如果更新操作中涉及关键字id,更新表单的jsp页面要回传id,不然id默认为0.而mysql的id从1开始。
可以使用隐藏域返回id
<input type="hidden" name="bookID" class="form-control" value="${QBook.bookID}" >
完整form表单如下:
<form action="${pageContext.request.contextPath}/book/updateBook" method="post"> <div class="form-group"> <input type="hidden" name="bookID" class="form-control" value="${QBook.bookID}" > <label>书籍名称</label> <input type="text" name="bookName" class="form-control" value="${QBook.bookName}" required> </div> <div class="form-group"> <label>书籍数量</label> <input type="text" name="bookCounts" class="form-control" value="${QBook.bookCounts}" required> </div> <div class="form-group"> <label>书籍详情</label> <input type="text" name="detail" class="form-control" value="${QBook.detail}" required> </div> <div class="from-group"> <input type="submit" class="form-control" value="修改"> </div> </form>