javabean和表单提交执行顺序问题
这是我的问题:
我有一个 html 表单,在用户填写所有必填字段后,我需要做两件事。
第一。我使用 jsp:setProperty name="bean" property="*"/ 将值保存在 javabean 中 致电
第二。我转到新页面。然而,我移动到的页面取决于用户在其中一个字段中提交的内容。
目前,我的按钮上有以下 javascript 调用来执行页面更改:
$("#entry").submit(function(){
如果(验证()){
var value = $("#dataSource").val();
if(值==“生产”){
window.location="CAPARequestProduction.jsp";
}else if(value == "客户/保修"){
window.location="CAPARequestCustWarr.jsp";
}其他{
Alert("无效选择:请选择生产或客户/保修");
}
}
});
jsp:setProperty 调用循环遍历这些值并将它们存储在 bean 中。
这是我的问题......当按下提交按钮时,将调用 javascript 并进行字段验证,并且浏览器开始访问新的 .jsp,但是一旦完成并且在新的 .jsp 加载之前setProperty 调用执行,执行后它返回到原始页面。
如何同时执行 javascript 调用和 setProperty 调用并仍移至下一页?
谢谢。
Here's my issue:
I have a html form that after a user fills in all the required fields I need to do two things.
1st. I save the values in a javabean using the jsp:setProperty name="bean" property="*"/
call
2nd. I move to a new page. However the page I move to depends on what the user has submitted in one of the fields.
I currently have the following javascript call on my button to execute the change of page:
$("#entry").submit(function(){
if(validate()){
var value = $("#dataSource").val();
if(value == "Production"){
window.location="CAPARequestProduction.jsp";
}else if(value == "Customer/Warranty"){
window.location="CAPARequestCustWarr.jsp";
}else{
alert("INVALID CHOICE: Please choose Production or Customer/Warranty");
}
}
});
THe jsp:setProperty call loops through the values and stores them in the bean.
Here's my issue....when the submit button is pressed, the javascript is called and the field validation occurs and the browser starts to access the new .jsp, however as soon as it has finished and before the new .jsp has loaded the setProperty call executes and after it executes it returns me to my original page.
How can I perform both the javascript call and the setProperty call and still move to the next page?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将表单中的操作值设置为一个称为重定向的中间 jsp 解决了这个问题。从重定向中我可以调用 jsp:setProperty 来设置 bean 中的所有值。验证也在redirect.jsp 中使用scriplet 和jsp:getProperty 函数完成。从那里我使用 jsp:forward 函数移动到相应的页面。
I solved this problem by setting the action value in my form to an intermediate jsp I called redirect. From within redirect I was able to call the jsp:setProperty which set all the values in the bean. The validation was also done in the redirect.jsp using scriplets and the jsp:getProperty function. From there I moved to the corresponding page using the jsp:forward function.