为什么html中form的method是get,为什么我最后提交数据时地址栏没有显示数据,不是post没有吗?
html文件代码如下
servlet的java源代码如下
为什么我最后提交数据时地址栏没有显示数据
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >
<head></head>
<body>
<form id = "form1" name = "form1" method = "post" action ="servlet/ThreeParams">
<table width = "234" border = "2">
<tr>
<td width = "90">param1</td>
<td width = "90"><input name = "param1" type = "text" id="param1" /> </td>
</tr>
<tr>
<td width = "90">param2</td>
<td width = "90"><input name = "param2" type = "text" id="param2" /> </td>
</tr>
<tr>
<td width = "90">param3</td>
<td width = "90"><input name = "param3" type = "text" id="param3" /> </td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" value="提交">
</label></td>
</tr>
</table>
</form>
</body>
</html>
servlet的java源代码如下
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ThreeParams extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter pw = resp.getWriter();
resp.setContentType("text/html");
pw.println(req.getParameter("param1"));
pw.println("<br/>");
pw.println(req.getParameter("param2"));
pw.println("<br/>");
pw.println(req.getParameter("param3"));
pw.println("<br/>");
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req,resp);
}
}
为什么我最后提交数据时地址栏没有显示数据
...全文
相关推荐
Form表单中method=post/get两种数据传输的方式的区别
Form提供了两种数据传输的方式—get和post,Form中的get和post方法,在数据传输过程中分别对应了HTTP协议中的GET和POST方法,感兴趣的朋友可以了解下,或许对你学习get/post有所帮助
HTML中Form表单的method属性使用介绍
1 method是指定数据如何发送到服务器的一个属性 2 只可能是post和get post:官方解释是把数据通过post会话传送到服务器。实际就是提交数据。 get:将表单中数据的按照variable=value的形式,添加到action所指向的URL后面,并且两者使用“?”连接,而各个变量之间使用“&”连接;一般用来从服务器得到数据。 3,默认是get,所以一般我们都要指定为post 举个例子: 比如说有2个页面,a.htm和b.asp,你想将a.htm页面表单中的值传递给b.asp页面。 那么在a.htm中就会有如下的表单代码: 复制代码代码如下: <form id=”form1″
Java 中 Form表单数据的两种提交方式
本文给大家分享java中form表单数据的两种提交方式,分别是get从制定的服务器中获取数据,pos方式提交数据给指定的服务器处理,本文给大家介绍的非常详细,需要的朋友参考下吧
关于HTML的Form的get和post
NULL 博文链接:https://lukejin.iteye.com/blog/591646
html中_的method=post和method=get的区别
html中_的method=post和method=get的区别,详细的解释。


