为什么不能submit

在做的项目是从webwork转成struts的,同时有些思路和我以前做的不太一样。所以
			String submitOkStr = request.getParameter("submitOk");;
boolean submitOk = false;
if (submitOkStr != null);
submitOk = true;
//在这里加这样一句,是用来在分页操作时,这时候用户只是点击了下一页的按钮,
//并没有点击submitOK按钮,这样就搜索不出数据。
String pageNoStr = request.getParameter("pageNo");;
if (submitOk||(pageNoStr!=null);); {
String status = request.getParameter("status");;
long userId = getLongParameter(request, "userId");;
long reportId = getLongParameter(request,"reportId");;


if (status != null && status.length(); < 1);
status = null;

int pageNo = getIntParameter(request, "pageNo", 1);;
int pageSize = getIntParameter(request, "pageSize", 10);;


PageList reportLogs = reportLogProvider.getReportLogs(status,
userId,reportId,pageNo,pageSize);;
request.setAttribute("PageList", reportLogs);;
}

结果我在分页的时候,总是看不到分页的结果,在action里面设置了断点(不是在第一行里面设置的),总是不执行,后来才发现前面有一个if语句。
在 HTML 表单中,按钮的 `type` 属性有同的行为表现。 当按钮的 `type` 属性为 `button` 时,它只是一个普通的按钮,会触发表单的默认提交行为。因此,在点击这种按钮时,可以通过 JavaScript 代码来实现页面跳转,例如: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <form id="registrationForm"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required><br> <label for="password">密码:</label> <input type="password" id="password" name="password" required><br> <button type="button" id="jumpButton">跳转</button> </form> <script> const registrationForm = document.getElementById('registrationForm'); const jumpButton = document.getElementById('jumpButton'); jumpButton.addEventListener('click', function () { window.location.href = "day1.3.html"; }); </script> </body> </html> ``` 当按钮的 `type` 属性为 `submit` 时,点击按钮会触发表单的默认提交行为。表单会将数据提交到表单 `action` 属性指定的 URL 地址(如果没有指定 `action`,则提交到当前页面),并且页面会重新加载以显示响应结果。这就会导致原本的 JavaScript 跳转代码可能无法正常执行,因为页面已经开始处理表单提交的操作了。例如: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <form id="registrationForm"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required><br> <label for="password">密码:</label> <input type="password" id="password" name="password" required><br> <button type="submit" id="submitButton">提交</button> </form> <script> const registrationForm = document.getElementById('registrationForm'); const submitButton = document.getElementById('submitButton'); submitButton.addEventListener('click', function () { // 由于表单提交,下面的跳转代码可能会执行 window.location.href = "day1.3.html"; }); </script> </body> </html> ``` 如果想在 `type` 为 `submit` 的按钮点击时实现跳转,需要阻止表单的默认提交行为,使用 `event.preventDefault()` 方法,示例如下: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <form id="registrationForm"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required><br> <label for="password">密码:</label> <input type="password" id="password" name="password" required><br> <button type="submit" id="submitButton">提交</button> </form> <script> const registrationForm = document.getElementById('registrationForm'); registrationForm.addEventListener('submit', function (event) { event.preventDefault(); window.location.href = "day1.3.html"; }); </script> </body> </html> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值