测试
后端代码
//根据小区查询区管信息
@ResponseBody
@RequestMapping("CxQg")
public JSONObject CxQg(HttpServletRequest request,String xqName,String qgID) throws UnsupportedEncodingException {
xqName = new String(xqName.getBytes("ISO-8859-1"), "utf-8") + "";
if (qgID != null) {
qgID = new String(qgID.getBytes("ISO-8859-1"), "utf-8") + "";
}
System.out.println(xqName);
System.out.println(qgID);
JSONObject jsonObject = new JSONObject();
qglists = qgServic.CxQg(xqName,qgID);
jsonObject.put("qglists", qglists);
System.out.println(qglists);
return jsonObject;
}
前端代码
//根据小区查询区管信息
function selQg(){
var xqName = $('#xqNameId').val();
var qgID=$('#qgID').val();
var html ="";
$.ajax({
url:"CxQg.action",
async : false,
dataType : "json",
data : {
"xqName" : xqName,
"qgID" : qgID,
},
success : function(data) {
$("#qgInfo").empty();
var d=data.qglists;
for(var i=0;i<d.length;i++){
var id=d[i].id;
var QgID=d[i].qgID;
var XqName=d[i].xqName;
var InstallAd=d[i].installAd;
var RecordTime =d[i].recordTime ;
var qgFl=d[i].qgFl;
/* if(i%2 == 1){
html+= "<tr class='gradeX odd'>";
}else if(i%2 == 0){
html+= "<tr class='gradeX even'>";
} */
html+="<td class='text-center'><input type='checkbox' name='pchecked' value='"+QgID+"'/></td>";
html+="<td class='text-center'>"+QgID+"</td>";
html+="<td class='text-center'>"+XqName+"</td>";
html+="<td class='text-center'>"+InstallAd+"</td>";
html+="<td class='text-center'>"+RecordTime+"</td>";
if(qgFl=="4"){
html+="<td class='text-center'>"+"0.5单系统"+"</td>";
}else if(qgFl=="2"){
html+="<td class='text-center'>"+"双系统"+"</td>";
}
else if(qgFl=="3"){
html+="<td class='text-center'>"+"老款双系统"+"</td>";
}
else{
html+="<td class='text-center'>"+"单系统"+"</td>";
}
html+="</tr>";
}
html+="</tbody>"
html+="</table>";
html+="</div>";
$("#qgInfo").append(html);
}
})
document.getElementById("aa").style.display="none";
document.getElementById("xincreate_table_body").style.display="block";
}
sql语句
<!-- 根据小区查询区管信息 -->
<select id="CxQg" parameterType="Qg" resultMap="qg" >
select qg.QgID,qg.XqName,qg.InstallAd,qg.RecordTime,qg.QgFl
from T_QgInfo qg,T_JzqInfo jzq where qg.JzqID=jzq.JzqID and ( QgFl=1 or QgFl=2 or QgFl=3 or QgFl=4)
<if test="xqName!='--选择小区名称--'">
and qg.xqName=#{xqName}
</if>
<if test="qgID!=null and qgID!=''">
and QgID=#{qgID}
</if>
order by qg.xqName,qg.QgID
</select>