jsp 写sql
$("#vehicleSourceID").combobox({
url:'<%=request.getContextPath()%>/rest/getcompany.jsp?companytype=1,2,5',
valueField:'id',
textField:'name',
value:"",
loadFilter:function(data){
var obj={id:"0",name:'-巴歌出行-'};
data.splice(0,0,obj);
return data;
}
});
<%@ page language="java" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="java.io.*" %> <%@ page import="javax.servlet.*" %> <%@ page import="javax.servlet.http.*" %> <%@ page import="java.net.*" %> <%@ page import="com.google.gson.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.*" %> <%@ page import="java.util.Date" %> <%@ page import="java.util.Map" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashSet" %> <%@ page import="java.util.Iterator" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.text.SimpleDateFormat" %> <%@ page import="org.apache.log4j.Logger" %> <%@ page import="net.joystart.data.DataBaseUtil" %> <% response.setCharacterEncoding("UTF-8"); response.setContentType("application/json; charset=utf-8"); String companytype = request.getParameter("companytype"); String parentid = request.getParameter("parentid"); String sql = "SELECT id,companyName name from t_base_company where isDelete=0"; if(companytype!=null){ sql += " AND companytype in("+companytype+")"; } if(parentid!=null){ sql += " AND parentid="+parentid; } //out.print(sql); List<Map<String, Object>> ret = DataBaseUtil.execute(sql); Gson gson = new Gson(); String str = gson.toJson(ret); out.print(str); %>