如何把JSP页面的URL参数传到JAVA后台去???
<script type="text/javascript">
<!--function run(){
var strTxt1 = document.forms[0].txt1.value;//document.getElementsByName("txt1").value;
var strTxt2 = document.getElementsByName("txt2");
document.forms[0].action="user.do?txt1=strTxt1&txt2=strTxt2";
document.forms[0].submit();
}
//-->
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<form action="" method = "post" onsubmit="return false">
<input type="text" name ="txt1">
<input type="text" name ="txt2">
<input type="button" value ="submit" onclick="run()">
</form>
</body>
</html>
问题:
document.forms[0].action="user.do?txt1=strTxt1&txt2=strTxt2";
这种写法在JAVA里执行 String txt1 = (String)request.getAttribute("txt1");
总是Null,怎么去jsp表单里txt1和txt2的值啊???
PS:用Struts的ActionForm这种做法当然能解决,我现在就是想用URL这种方法来取这些参数,请大侠们赐教,不胜感激
相关推荐
在jsp页面如何获得url参数
当一个url过来时,如:http://localhost:8080/pro/demo/hello.jsp?name=john,在hello.jsp页面,我们可以这样得到name的值: 代码如下: <% String path = request.getContextPath(); String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”; String name = request.getParameter(“name”);//用reques
ajax 提交数据到后台jsp页面及页面跳转问题
ajax 提交数据到后台jsp页面及页面跳转问题 我logincheck.jsp页面取传参数代码: String user=request.getParameter("user1"); String pwd=request.getParameter("pwd1"); login.jsp input 取2参数何用ajax 传给logincheck.jsp $.ajax({ type : "POST", url : baseUrl+"m/module/querymodulebyname.do", dataType:"json", data: { modName:title }, succes
JSP几种页面间传递参数实现的方法
JSP几种页面间传递参数实现的方法,希望能够提供一些帮助
jsp页面中获取servlet请求中的参数的办法详解
在JAVA WEB应用中,如何获取servlet请求中的参数,本文讲解了jsp页面中获取servlet请求中的参数的办法
JSP向后台传递参数的四种方式总结
下面小编就为大家带来一篇JSP向后台传递参数的四种方式总结。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧


Web 开发
