request.getParameter(“xxx”)的参数的取

2020-06-12  本文已影响0人  DUJUNHUI
1. Html中form表单中标签的name属性:

<form name="form" method="post" action="checkUser">  

请输入用户姓名:<input type="text" name="username">  

<input type="submit" name="Submit" value="提交">  

</form>  

request.getParameter(“username”);

 

2. Html中form表单提交时的action的参数

<form name="form" method="post" action="checkUser?Flag=1&Id=2">  

请输入用户姓名:<input type="text" name="username">  

<input type="submit" name="Submit" value="提交">  

</form>  

request.getParameter(“username”);

request.getParameter(“Flag”);

request.getParameter(“Id”);
问题:
${pageContext.request.contextPath}/product?method=add(有丢失参数的风险)
解决方式:<input type="hidden" name="method" value="add">
详解:
在form表单后通过?name=value方式提交有风险,后台可能会接收不到数据,我们可以用隐藏于来携带数据
eg:<input type="hidden"   name="username"    value="小明">
eg:<input type="hidden"   name="method"      value="add">

3. Html中url的内容

<a href="SortServlet?flag=5&temp=2" onclick="sort()"><img src="images/cbsj.jpg" /></a>

request.getParameter(“flag”);

request.getParameter(“temp”);

 

4. Ajax中的data

<form name="fm" action="" method="post">

<div style="margin-bottom:10px;">

<input class="TxtUserNameCssClass" type="text" id="UserCode" value="" />

</div>

<div style="margin-top:20px;">

<input class="TxtPasswordCssClass" type="Password" id="UserPwd" value="" />

</div>

</form>

<div class=IbtnEnterCssClass id="IbtnEnter" onclick="submitForm()">登录</div>

 

function submitForm(){

var UserCode = $("#UserCode").val();

var UserPwd = $("#UserPwd").val();

var mypwd = $.base64.btoa($.md5(UserPwd).toUpperCase());

var checkUserParams = {

usercode:UserCode,

userpwd:mypwd

};

$.ajax({

url : 'checkUser.asp?mathid='+Math.random(),

type : 'post',

data : checkUserParams,

dataType:'json',//接受数据格式

success : function(data) {

},

failure : function(data) {

}

});

}

 

request.getParameter("usercode");

request.getParameter("userpwd");
上一篇 下一篇

猜你喜欢

热点阅读