我用jQuery调用java业务类的方法这样有什么问题?
我直接上代码了,我刚学Jquery。
要求是,当我点击页面的下拉列表选择不同的分数的时候,通过jQuery跳到java类中,再由这个类去访问数据库,得到一个集合,要将这个集合遍历以表格的形势显示在页面中,
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
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>信息显示</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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
<!--
.STYLE2 {font-size: 24px}
-->
</style>
<script type="text/javascript" src="jquery-1.2.3-intellisense.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#sel").change(function() {
var score =this.value;
alert(this.value);
$.ajax({
type: "POST",
url: "/biz/impl/InfoBizImpl.java/getBySql2",// 我要调用InfoBizzImpl类中的getBySql2这个方法
data:score, //这里是我要传入方法的参数
contentType: "application/json; charset=utf-8",
success: function(msg) {
$("#div1").html(msg);
},
error: function(xhr,msg,e) {
alert(msg);
}
});
});
});
</script>
</head>
<body>
<br>
<table width="400" border="0" align="center">
<tr>
<td class="STYLE2">请选择分数的查询条件</td>
</tr>
<tr>
<td><form name="form1" method="post" action="">
<label>
<select name="select1" id="sel">
<option value="0" selected>全部</option>
<option value="90">大于90分</option>
<option value="80">大于80分</option>
<option value="70">大于70分</option>
<option value="60">大于60</option>
<option value="50">不及格</option>
</select>
</label>
</form>
</td>
</tr>
<tr>
<td><table width="400" border="0">
<tr>
<td>编号</td>
<td>姓名</td>
<td>科目</td>
<td>成绩</td>
</tr>
<tr>
<hr/&