[size=medium]构件自己的函数库首先将自己所见的JS函数的包含进JSP页面中,具体如下:[/size]
<script language="JavaScript" type="text/javascript" src="example.js"></script>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>构件自己的Ajax函数库</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">
<script language="JavaScript" type="text/javascript" src="example.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
<select id="product" size="1" onchange="order()">
<option value="1" selected>苹果</option>
<option value="2">西瓜</option>
<option value="3">荔子</option>
</select>
数量:<input id="num" size="10" type="text"><br>
单价:<input id="price" size="10" type="text">
总价:<input id="result" size="10" type="text">
</body>
</html>