我在下面给出了一个jsp页面
<%@page import="newpack.SendMailJavaToXsl07022013"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script language="javascript">
<!--
// <![CDATA[
function Button1_onclick() {
<%
SendMailJavaToXsl07022013 oaa = new SendMailJavaToXsl07022013();
oaa.mainClass();
out.print("Sdasd");
System.out.println( "In getDate() method" );
%>
}
// ]]>
</script>
</head>
<body>
<%=request.getParameter("key")%><br/>
<input name="send mail" id="Button1" type="button" value="button" onclick="return Button1_onclick()" onfocus="dfgdgf"/>
</body>
</html>
我希望函数 Button1_onclick() 仅在单击按钮后执行。但是它在页面加载时执行,并且在按钮单击时从不执行。这段代码有什么问题?