首页 > Web开发 > 详细

JSP的几种参数传值

时间:2016-01-04 02:09:39      阅读:176      评论:0      收藏:0      [点我收藏+]

一、超链接
<a href="P.jsp?username=zhangshan&pwd=123456&age=25"> 链接</a>
?
二、form表单
??? 1.可显示的控件
????? <input type="text" name="username">
?
??? 2.如果要传递的值,不需要显示在页面上
????? (1)<input type="hidden" name="pwd" value="<%=pwd%>">
????? (2)<form action="XXX.jsp" method="post"></form>
?
三、JSP的include和forward标签
??? <jsp:include flush="true" page="T.jsp?username=zhangshan&pwd=123456678">
???? <jsp:param name="age" value="28"/>
??? </jsp:include>
?
四、javascript方式
??? script type="text/javascript">
???? function demo(){
? var v = document.all(‘username‘).value;
? location.replace("V.jsp?username="+v+"&age=25");
?}
??? </script>
??? <input type="text" name="username"><br>
??? <input type="button" value="href点击" onclick="location.href=‘V.jsp?pwd=123456‘"><BR>
??? <input type="button" value="replace点击"?
?????????? onclick="location.replac(‘V.jsp?pwd=123456789‘)">
??? <br>
????
??? <input type="button" value="动态取值" onclick="demo()">
?
注:数据提交方式分为get和post两种
1、get和post的区别
A.GET请求只能处理小数据<2K
POST可以用来提交大数据
B.post提交方式相对而言,比较安全
get只是适合于小数据的传递,也就是说,只有post才能传递大数据,比如在文件上传时,就必须将method
指定为post
?
2、用post提交的情况:
当你的form表单的method属性指定为post,其提交方式才为post
其他的所有情况统统为get请求?

JSP的几种参数传值

原文:http://gaojingsong.iteye.com/blog/2268297

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!