gpt4 book ai didi

java - 将输入类型 ="image"提交给另一个 servlet 未能返回任何参数

转载 作者:行者123 更新时间:2023-12-01 15:15:39 24 4
gpt4 key购买 nike

servlet1:

我正在尝试将参数传递给另一个 servlet2:

..

out.print("<input type='text' name='someText' src='someSrc' onclick='submit()'/>");

..

单击它 - servlet2 正在加载。

servlet2:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
Enumeration params = request.getParameterNames();
while (params.hasMoreElements())
{
out.print("parameter: " + (String)params.nextElement() + "</br>");
}
}

我的输出 --> someText到目前为止一切顺利!

但是当我的输入类型是图像时,我的输出为空:

out.print("<input type='image' name='someText' src='someSrc' onclick='submit()'/>");

有什么建议吗?

最佳答案

根据 HTML 规范,input type="image" 将用作图像映射。当最终用户单击图像 map 时,Web 浏览器会将鼠标指针的 x 和 y 位置发送到服务器。

out.print("<input type=\'image\' name=\'imgButton\' src=\'flowsheet/images/submit_button.gif\'/>");

提交的值将以 imgButton.ximgButton.y 形式提供

但是,如果您只想在页面中使用样式按钮来提交数据。使用 input type="submit" 可以为按钮指定 CSS 背景图像。

关于java - 将输入类型 ="image"提交给另一个 servlet 未能返回任何参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11641657/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com