package fox.math.kmust;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class DoubleSelect extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String xmlRealPath = getServletContext().getRealPath("/Data.xml");
File xmlFile = new File(xmlRealPath);
Document document = null;
try {
document = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(xmlFile);
} catch (SAXException e) {
System.err.println("SAX错误:" + e.getMessage());
} catch (ParserConfigurationException e) {
System.err.println("配置错误:" + e.getMessage());
}
String id = request.getParameter("id");
String value = document.getElementsByTagName("class").item(
Integer.parseInt(id)).getFirstChild().getNodeValue().trim();
response.setContentType("text/xml");
response.setCharacterEncoding("gbk");
PrintWriter out = response.getWriter();
out.print(value);
out.close();
}
}
基于Ajax的二级联动下拉列表.rar
需积分: 10 156 浏览量
2010-08-16
23:31:43
上传
评论 1
收藏 8KB RAR 举报
qs463503059
- 粉丝: 17
- 资源: 92
最新资源
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
- Pyqt5项目框架-PyQt项目开发实践
- 基于C通过MQTT的智能农业大棚管理系统(本科毕业设计)
- python+CNN的网络入侵检测算法源码.zip
- js 实现记住密码功能 js.cookie.min.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈