每个人。我是一个新的 Java 精益者。我只是在尝试获取 JSP 中的参数时遇到问题。这是代码:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="Rocky.testRocky" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script>
function clickMouse()
{ alert("hello");
<%
String fn=request.getParameter ("first_name");
%>
var m="<%=fn%>";
alert(m);
}
</script>
</head>
<body style="margin:0px;">
<label id="coordiv" style="width:80px;height:20px;background:#DDDDDD" onmousemove="changeColor(id)" onmouseout="clearCo(id)" onClick="clickMouse(id)" >last week</label>
<form action="test3.jsp" id="myForm" method="post" onsubmit="clickMouse()">
First Name: <input type="text" name="first_name" >
<input type="submit" name="hello" value="Submit">
</form>
</body>
</html>
alert(m) 将始终为空。有人能帮我吗?非常感谢