简体   繁体   English

为什么我不能在表单中使用request.getParameter

[英]Why i can't use request.getParameter in my form

i have a question about using request.getParameter() , i knew that it can use to post the value using request.getParameter, Is it necessary match request.getParameter and <input> ??? 我有一个关于使用request.getParameter() ,我知道它可以用来使用request.getParameter发布值,是否有必要将request.getParameter<input>匹配?

My original code in HTML: 我的原始HTML代码:

<INPUT type=submit name="submit" value="download">

In JSP: 在JSP中:

String start = request.getParameter("submit");

Now I want to change a button and use div 现在我想更改一个按钮并使用div

div name="submit"id="submit" class="btnStyleFunc"
onclick="document.body.style.cursor='wait';this.disabled='true';
document.getElementById('form').submit();">

But it doesn't work, anyone can help me ? 但这不起作用,任何人都可以帮助我吗?


Now i use the method below, but another problem is raised...the action does not stop... 现在我使用下面的方法,但是又出现了另一个问题...动作没有停止...

String start = request.getParameter("submit1");

<input type=hidden name=submit1 value=download>
<div class="btnStyleFunc" onclick="document.body.style.cursor='wait';
this.disabled='true';document.getElementById('form').submit();">

Does anyone know what the problem is ? 有谁知道是什么问题?

A clicked submit button is a successful form control and its name/value pair will be submitted to the server in the form data. 单击提交按钮是成功的表单控件,并且其名称/值对将以表单数据提交到服务器。

If you submit a form with JavaScript, there is no clicked submit button, so it won't appear in the data. 如果使用JavaScript提交表单,则不会单击提交按钮,因此它不会显示在数据中。 A div cannot have a name and is not a form control anyway — it isn't a submit button, even if it triggers JavaScript that submits the form. div不能有name ,也不能是表单控件-它不是提交按钮,即使它触发了提交表单的JavaScript。

Using a div with JavaScript also breaks the form for: 将div与JavaScript一起使用还会破坏以下形式:

  • Anyone not using a mouse/trackpad/etc to navigate the page (a div won't get the focus when tabbing through interactive elements) 任何不使用鼠标/触控板/等等来浏览页面的人(在交互元素之间切换时,div不会获得焦点)
  • Anyone with JavaScript disabled 任何禁用了JavaScript的人
  • Anyone using a screen reader in forms mode (div elements are not form controls). 在窗体模式下使用屏幕阅读器的任何人(div元素不是窗体控件)。

Use a real submit button instead. 请使用真实的提交按钮。

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

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