<servlet-name>selectCropDepart</servlet-name>
<servlet-class>pub.SelectCropDepartServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>selectCropDepart</servlet-name>
<url-pattern>/selectCropDepart</url-pattern>
</servlet-mapping>
</web-app>
SelectCropDepartServlet.Java Servlet类代码如下
/**
* 从sys04_Machine表中取数据进行二级下拉菜单(公司,部门)及关联的servlet类
* @author 邓浩
*/
public class SelectCropDepartServlet extends HttpServlet {
public SelectCropDepartServlet() {
super();
}
public void destroy() {
super.destroy(); }
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");
String targetId = request.getParameter("id").toString();
String xml_start ="<selects>";
String xml_end = "</selects>";
String xml = "";
try{
Conn conn=new Conn();
DataTable dt=new DataTable();
String Sql="select * from sys04_Machine where cropid="+targetId;
////System.out.println("Sql:"+Sql);
xml+= "<select><value>all</value><text>所有部门</text></select>" ;
int i=0;
if (conn.querySql(Sql,dt)){
while (i<dt.getRowCount()){
xml+= "<select><value>"+dt.getItemForName(i,"MachID").toString()+"</value><text>"+dt.getItemForName(i,"MachName").toString()+"</text></select>";





