action接收jsp传来的值,主要的方式是将数据放在request对象中,然后在另一个页面拿到这个数据即可,代码如下:
A.jsp :通过post 和get、连接都可以传
a标签连接的:
'>传递到B页面
B.jsp :
B页面通过如下代码接收
<%
String name=request.getParameter("name");
out.println("接收到:"+name);
%>
action接收jsp传来的值,主要的方式是将数据放在request对象中,然后在另一个页面拿到这个数据即可。
代码如下:
A.jsp :通过post 和get、连接都可以传
a标签连接的:
'>传递到B页面B.jsp :
B页面通过如下代码接收:
<%String name=request.getParameter("name");out.println("接收到:"+name);%>
贴代码 有点乱可以点进去: 网页链接
引用:
/**
* 处理post请求.
* @param url 请求路径
* @param params 参数
* @return json
*/
public static String post(String url,Map
CloseableHttpClient httpclient = HttpClients.createDefault(); //实例化post方法
HttpPost httpPost = new HttpPost(url); //处理参数
List
Set
nvps.add(new BasicNameValuePair(key, params.get(key).toString()));
} //结果
CloseableHttpResponse response = null;
String content=""; try { //提交的参数
UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(nvps, "UTF-8"); //将参数给post方法
httpPost.setEntity(uefEntity); //执行post方法
response = httpclient.execute(httpPost); if(response.getStatusLine().getStatusCode()==200){
content = EntityUtils.toString(response.getEntity(),"utf-8");
System.out.println(content);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} return content;
}
和直接接受表单的submit应该是一样的,这里有篇文章,你也可以看看:
http://www.cnblogs.com/lhb25/p/html5-formdata-tutorials.html
request.getParameter("abc")
abc为表单域的名称,例如: