如何模拟网页内的按钮动作并获取相应返回信息,请大侠赐教 有一个网页,上面有个文本框和一个提交按钮。能否用Java程序实现信息输入和提交,并获取提交后的信息。如何实现?请各位大侠赐教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to emon123 :刚接触Java,能给个小的例子吗?谢了 很简单的,用jsp就可以实现了!input.jsp页面内容:<body><% String msg=""if(request.getParameter("msg")!=null){ msg=request.getParameter("msg");}%><form action='input.jsp' method='post'>请输入内容:<input type='text' name='msg' /><br/><input type='submit' value='提交' /></form><!--此处显示你输入的内容--><div><%=msg %></div></body> 还是先看看JAVA,JSP,SERVLET吧 1.你想干么? 爬虫么。。 httpclient。。2.jsp 一个表单 ,一个提交?获得信息?伪代码:<form action = "" method> <input type = "text" name = "username"> <input type = "submit" value = "提交"></form>后台:String username = (String)reuqest.getParamter("usernmae");3.请尽量将问题说明白。 jsp页面<form action = "你的servlet或action或jsp页面" method="post"><input type = "text" name = "test"><input type = "submit" value = "提交"></form>后台:String username = (String)reuqest.getParamter("test"); 这个网页是某网站的一个页面,我想在本机用Java程序实现文本输入和按钮的点击动作,并获取网站反馈信息如“提交成功”或“文本格式不正确”,能否实现? 返回成功不成功,只能是你这边判断!你模拟人家网页的cookie呢!人家只返回人家的成功信息!你要吧人家的成功信息转换成你的!httpclient可以的!你从网上找找! 你想模拟表单提交吧,最简单的是用httpclient可以用httpclient来模拟post表单提交,并获取response响应结果,然后进行分析,获取你所要的内容 前台用 Java??? JavaScript吧!---------------------------细粒度权限管理软件 试用版下载www.metadmin.com 可以用javascript去实现,没必要那么麻烦吧。你的js代码只要写到页面body里面,不要写到触发事件里面。 用httpclient可以模拟按钮动作吗,怎样? httpclient使用NameValuePair向文本框传参数是使用的是文本框的id,还是name还是其他的?本人太弱,也不知道问得对不对 呵呵,类似文本框的name,比如html提交表单,提交的都是name对应着value 首先:比如你是做一个表单时注册用的话,可以现在客户端写一段脚本约束填写的内容,不如填写的内容不能为空,长度什么的,不能为空也提交吧。如果OK,那么才是提交数据。用一 form表单提交到另一个判断页面,如果学了MVC的话可以提交到一个Servlet上判断,没学的话,就提交到一个jsp页面即可,然后在那个页面对提交的数据进行判断,成功则可用javascript弹出窗口的模式提示成功,失败也可以。 不用强制转化,直接String username = reuqest.getParamter("test");给你个更详细的吧:<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> </head> <body> <form action="/项目名/Servlet名" method="post" name="login"> 用户名: <input type="text" name="userName" /><br>  <input type="submit" value="确定" /> </form> </body></html>servlet:import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class ActionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userName = request.getParameter("userName"); }}当然还要在web.xml中配置下servlet~~你可以看看关于servlet的资料 ireport 错误 求助啊 急急急! heritrix-1.14.3如何抓取一个网站更新后的页面 struts2 注册提交到action luncene2.0 高亮问题!!!!!!!!!! 第一天写JSP就把机子搞砸了,项目经理看了也不明情况!! 请问各位师兄,poi的例子在什么地方! 对于resin+IIS的配置总结,仅给大家参考一下。 100分解惑 为什么不能写入数据!有代码 jsp 页面显示不出。过来瞧瞧 。 webRoot右键怎么创建不了jsp文件?
input.jsp页面内容:
<body>
<% String msg=""
if(request.getParameter("msg")!=null){
msg=request.getParameter("msg");
}
%>
<form action='input.jsp' method='post'>
请输入内容:<input type='text' name='msg' /><br/>
<input type='submit' value='提交' />
</form>
<!--此处显示你输入的内容-->
<div><%=msg %></div>
</body>
爬虫么。。
httpclient。。
2.jsp 一个表单 ,一个提交?获得信息?
伪代码:
<form action = "" method>
<input type = "text" name = "username">
<input type = "submit" value = "提交">
</form>
后台:
String username = (String)reuqest.getParamter("usernmae");
3.请尽量将问题说明白。
jsp页面
<form action = "你的servlet或action或jsp页面" method="post">
<input type = "text" name = "test">
<input type = "submit" value = "提交">
</form>
后台:
String username = (String)reuqest.getParamter("test");
httpclient可以的!你从网上找找!
---------------------------
细粒度权限管理软件 试用版下载
www.metadmin.com
本人太弱,也不知道问得对不对
form表单提交到另一个判断页面,如果学了MVC的话可以提交到一个Servlet上判断,没学的话,就提交到一个jsp页面即可,然后在那个页面对提交的数据进行判断,成功则可用javascript弹出窗口的模式提示成功,失败也可以。
String username = reuqest.getParamter("test");
给你个更详细的吧:<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head> <body>
<form action="/项目名/Servlet名" method="post" name="login">
用户名:
<input type="text" name="userName" /><br>
 <input type="submit" value="确定" />
</form>
</body>
</html>servlet:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class ActionServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String userName = request.getParameter("userName");
}}
当然还要在web.xml中配置下servlet~~你可以看看关于servlet的资料