简体   繁体   English

从JSP用Javascript发布表单

[英]Posting form in Javascript from JSP

Question level : Intermediate / Beginner 问题级别:中级/初学者

I created a form with 我创建了一个表单

`method="post" action="eh.do" onsubmit="return Form1_Validator(this)"`

The validation is successful and works fine when I hit submit. 验证成功,当我点击提交时,效果很好。

But on the servlet, I have a concatenate function to merge the values together. 但是在servlet上,我有一个连接函数将这些值合并在一起。

When the Javascript is turned on, ie when I write onsubmit="return Form1_Validator(this)" it shows: 当Javascript打开时,即当我写onsubmit="return Form1_Validator(this)"它显示:

java.lang.NullPointerException
    java.lang.String.concat(Unknown Source)
    EditHelper.doPost(EditHelper.java:27)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

But once the Javascript is disabled ie I delete out onsubmit="return Form1_Validator(this)" , it works fine. 但是一旦禁用Javascript,即删除了onsubmit="return Form1_Validator(this)" ,它就可以正常工作。

If all conditions are true, my script returns 如果所有条件都满足,我的脚本将返回

return (true);

Is this the problem? 这是问题吗?

I tried return(theForm); 我尝试了return(theForm); but the problem remains the same! 但是问题仍然存在!

I'd use Firebug to see how the form submit request parameters change if you add your onsubmit handler. 如果您添加onsubmit处理程序,我将使用Firebug来查看表单提交请求参数如何更改。 I guess your javascript code is somehow influencing those parameters and once you see what happens, it might become obvious why this is. 我想您的javascript代码会以某种方式影响这些参数,一旦您看到发生了什么,为什么会这样就很明显了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM