初学者的问题

懒得优化能跑就行 2003-09-14 09:40:40
servlet里的doGet()和doPost()都会返回浏览器页面信息,请问那还有什么不同?疑惑
...全文
72 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
pzl686 2003-09-14
  • 打赏
  • 举报
回复
还是这样的好
public void service(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException
{

}
Keepers 2003-09-14
  • 打赏
  • 举报
回复
那还不如直接写一个service方法呢,什么请求都接受
public void service(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException
{

}

seaman0916 2003-09-14
  • 打赏
  • 举报
回复
这有种简单的方法:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
.............
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException
{
doPost(response,request);
}

这样的话,两种传递方法都能处理了! 哈哈
Keepers 2003-09-14
  • 打赏
  • 举报
回复
doGet 只响应画面form的method=get的请求
doPost只响应画面form的method=post的请求
并且get请求是明文传送的,地址栏有你提交的信息
post请求使用数据包方式传送的在地址栏没有你提交的信息
get提交的数据昌都有限制
post理论上是没有限制的
seaman0916 2003-09-14
  • 打赏
  • 举报
回复
不同之处就是它处理的传递方法不同!

当参数是通过Get方法传递时,要使用doGet()处理
当参数是通过Post方法传递时,要使用doPost()处理

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧