//------------------------------javascript---------------------------------------
<script type="text/javascript">
$(function() {
$('#cfgChexiId').change(function(){
alert("---");
var dicts = $("#cfgChexiId").val();
if(""!=dicts){
$.get("${rootUrl}app/wx/kunlun/choOil/getByParentId?parentId=" + dicts, function(data){
var msg = eval("(" + data + ")");
$("#changjiaName").html("<option>请选择</option>");
for(var i=0,len=msg.length;i<len;i++){
var op="<option value='"+msg[i].id+"'";
op+=">"+msg[i].name+"</option>";
$("#changjiaName").append(op);
}
});
}
});
})
</script>
//-----------------------------controller---------------------------------------
@RequestMapping(value = "/wx/kunlun/choOil/getByParentId")
protected void doGet(@ModelAttribute("queryModel") SystemDataDictModel queryModel,HttpServletRequest req, HttpServletResponse response)
throws IOException {
// queryModel.setDictType(Finals.DataDict.valueOf(queryModel.getType()));
List<SystemDataDict> list = systemDataDictManager.listQuery(queryModel);
StringBuilder json = new StringBuilder();
json.append("[");
if (null != list)
for (int i = 0; i < list.size(); i++) {
SystemDataDict systemDataDict = list.get(i);
if (i == list.size() - 1) {
json.append("{id:'").append(systemDataDict.getId())
.append("',name:'").append(systemDataDict.getValue())
.append("'}");
} else {
json.append("{id:'").append(systemDataDict.getId())
.append("',name:'").append(systemDataDict.getValue())
.append("'},");
}
}
json.append("]");
response.getWriter().println(json.toString());
}