小白求教 没效果,求大神。。
Service内容
@Service
public class TexeDemoService extends BaseService {
public Map Xl(){
String sql="select HM,HMLX from yp_viz_refusehm";
String buildCountSql = buildCountSql(sql);
int queryForInt = this.getJdbcTemplate().queryForInt(buildCountSql);
List queryForList = this.getJdbcTemplate().queryForList(sql);
Map resultMap = new HashMap();
resultMap.put("int", queryForInt);
resultMap.put("list",queryForList);
return resultMap;
}
}
Controller内容
@Controller
public class XuLiangController extends BaseActionController {
@Autowired
private TexeDemoService xuLiangService;
public void Xl(HttpServletRequest request,HttpServletResponse response){
Map xl = xuLiangService.Xl();
sendJSON(response, JsonUtils.MapToJsonStr(xl));
}
}
jsp内容
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script src="http:****/chaXun.js"></script>
</head>
<body>
<table class="ui-table" width="800" id="studentInfo">
<caption>
<h2>学生资料</h2>
</caption>
<thead>
<tr>
<th style="width:45px">序号</th>
<th>序号类型</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"><input type="button" value="加载资料"
onclick='DisplayInfo()'></td>
</tr>
</tbody>
</table>
<script type="text/javascript">
</script>
</body>
js内容
function DisplayInfo() {
tbody = $("#studentInfo").find("tbody");
tbody.empty();
$.ajax({
type : "Post",
url : "/zhyy/xuLiang/Xl.do",
dataType: "json",
success : function(result) {
$.each(result,function(index, el) {
tbody.append("<tr><td>" + el.HM + "</td><td>" + el.HMLX + "</td></tr>");
});
},
});
}