参考于 http://blog.csdn.net/lhq13400526230/article/details/12427225#comments
作为一名初学者,记录下自己学习过程中的心得与总结
源码: jsp部分
$(function() {
// 下拉框选择控件,下拉框的内容是动态查询数据库信息
$('#lanmu').combobox({
url:'easyui!lanmu',
//不可编辑状态
cache: false,
panelHeight: 'auto',//自动高度适合
valueField:'classid',
textField:'classname',
value:"请选择栏目",
onHidePanel: function(){
$("#leibie").combobox("setValue",'请选择类别');
var lanmuid = $('#lanmu').combobox('getValue');
$.ajax({
type: "POST",
url: "/SSSH/easyui!leibie?classid="+lanmuid,
cache: false,
dataType : "json",
success: function(data){
$("#leibie").combobox("loadData",data);
}
});
}
});
$('#leibie').combobox({
//url:'itemManage!categorytbl',
editable:false, //不可编辑状态
cache: false,
panelHeight: 'auto',//自动高度适合
valueField:'id',
textField:'teacher'
});
});
<body>
<div id="tb" style="padding: 3px">
<form >
<span>所属栏目:</span>
<select id="lanmu" class="lanmu" style="width:160px; border: 1px solid #ccc"> </select>
<span>类别:</span>
<select id="leibie" class="leibie" style="width:160px; border: 1px solid #ccc"> </select>
</form>
</div>
</body>
转换Json字符串需要用到
public String toJsonArray(List list) throws IOException{
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request = ServletActionContext.getRequest();
JSONArray json = JSONArray.fromObject(list);
response.setCharacterEncoding("utf-8");// 指定为utf-8
response.getWriter().write(json.toString());// 转化为JSOn格式
return NONE;
}
得到关联的两个实体类需要转换成VO类。