小白求教 没效果,求大神。。

灬Mr.Xu灬 2015-09-02 04:12:20

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>");
});
},
});
}
...全文
85 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
灬Mr.Xu灬 2015-09-02
  • 打赏
  • 举报
回复
大概意思是 在Service查询数据库,再用Controller实现,再用js接收Controller的值,显示到jsp 不知道哪里出错,显示的是undefined。。。
zhanbaone 2015-09-02
  • 打赏
  • 举报
回复
没有看懂啥意思

87,955

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧