<a href="javascript:window.location.href='findPW.jsp?uname='+document.LoginForm2.username.value+'&loginType='+document.LoginForm2.logType.value">忘记密码? </a>
新页面用request.getParameter("loginType") 取不到值啊
新页面用request.getParameter("loginType") 取不到值啊
网页cq.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>cq.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head>
<body>
<script type="text/javascript">
</script>
测试页面. <br>
<a href="javascript:window.location.href='/web_chart/index.jsp?uname='+document.LoginForm2.username.value+'&loginType='+document.LoginForm2.logType.value">忘记密码? </a>
<form action="/web_chart/index.jsp" method="POST" name="LoginForm2">
<input type="text" name="username" value="jns">
<input type="text" name="logType" value="AAA">
<input type="submit" value="提交" />
</form>
</body>
</html>提交取值index.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>测试</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
输出结果是: <br>
<% request.setCharacterEncoding("UTF-8"); %>
uname:<%=request.getParameter("uname") %>
loginType:<%=request.getParameter("loginType") %>
</body>
</html>
运行时,正确取到值啊。
<a href="javascript:window.location.href='findPW.jsp?uname='+document.LoginForm2.username.value+'& amp;loginType='+document.LoginForm2.logType.value">忘记密码? </a>
新页面用request.getParameter("loginType") 取不到值啊可以改成这种方式,更清晰
<a href="javascript:findPass();">忘记密码</a>var findPass=function(){
var username=document.LoginForm2.username.value;
var logType=document.LoginForm2.logType.value;
var url="findPW.jsp?uname="+escape(username)+"&logType="+escape(logType);
window.open(url);
}加上escape,是解决中文get方式乱码。