哪位大侠用jsp+xml做过后台管理程序 不使用数据库 ?急啊 !``` 做过。但是数据太多了不行,少还可以。数据多就把一个大xml切成多个小xml 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?xml version="1.0" encoding="UTF-8"?><database> <ServerName>myLocalHost</ServerName> <DatabaseName>myDatabaseName</DatabaseName></database>package com.myproject.test;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document;import org.w3c.dom.NodeList;public class ReadDatabase { public static String serverName; public static String databaseName; public static String userName; public static String password; public static void readDatabase1() { DocumentBuilderFactory theDocumentBuilderFactory = DocumentBuilderFactory .newInstance(); String path = "D:\\Projects\\myproject\\src\\com\\myproject\\test\\database.xml"; try { DocumentBuilder theDocumentBuilder = theDocumentBuilderFactory .newDocumentBuilder(); Document theDocument = theDocumentBuilder.parse(path); theDocument.getDocumentElement(); NodeList nodelist; nodelist = theDocument.getElementsByTagName("ServerName"); if (nodelist.getLength() > 0) { serverName = (nodelist.item(0)).getFirstChild().getNodeValue(); System.out.println(nodelist.item(0).getNodeName() + "=" + serverName); } nodelist = theDocument.getElementsByTagName("DatabaseName"); if (nodelist.getLength() > 0) { databaseName = (nodelist.item(0)).getFirstChild() .getNodeValue(); System.out.println(nodelist.item(0).getNodeName() + "=" + databaseName); } nodelist = theDocument.getElementsByTagName("UserName"); if (nodelist.getLength() > 0) { userName = (nodelist.item(0)).getFirstChild().getNodeValue(); System.out.println(nodelist.item(0).getNodeName() + "=" + userName); } nodelist = theDocument.getElementsByTagName("Password"); if (nodelist.getLength() > 0) { password = (nodelist.item(0)).getFirstChild().getNodeValue(); System.out.println(nodelist.item(0).getNodeName() + "=" + password); } } catch (Exception e) { e.printStackTrace(); } } public static void main(String args[]) { readDatabase1(); }} 我所说的不是这个 是一个完整的程序可是对xml进行增删改查,最好还支持模糊查询 Servlet3.0 asyncListener中的onStartAsync方法不起作用 ejb3 log4j IBM面试题 【急】struts2为何不能如此封装数据?高手进!!! javascript中怎样调用import进jsp文件中java类中的函数? 请教weblogic如何配置,急,在线等!! 求源代码,用JAVA实现文件传输(不是做FTP),用socket来做。 java访问数据库的问题 求助:我的TOMCAT5.0能启动,但运行JSP程序报错! 以前返回的list<javabean>直接给前台展示了 现在要弄成JSON或者XML 怎么弄啊 急求回答 jdbc问题
<ServerName>myLocalHost</ServerName>
<DatabaseName>myDatabaseName</DatabaseName>
</database>
package com.myproject.test;import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document;
import org.w3c.dom.NodeList;public class ReadDatabase {
public static String serverName; public static String databaseName; public static String userName; public static String password; public static void readDatabase1() { DocumentBuilderFactory theDocumentBuilderFactory = DocumentBuilderFactory
.newInstance();
String path = "D:\\Projects\\myproject\\src\\com\\myproject\\test\\database.xml";
try {
DocumentBuilder theDocumentBuilder = theDocumentBuilderFactory
.newDocumentBuilder();
Document theDocument = theDocumentBuilder.parse(path);
theDocument.getDocumentElement(); NodeList nodelist; nodelist = theDocument.getElementsByTagName("ServerName");
if (nodelist.getLength() > 0) {
serverName = (nodelist.item(0)).getFirstChild().getNodeValue();
System.out.println(nodelist.item(0).getNodeName() + "="
+ serverName);
} nodelist = theDocument.getElementsByTagName("DatabaseName");
if (nodelist.getLength() > 0) {
databaseName = (nodelist.item(0)).getFirstChild()
.getNodeValue();
System.out.println(nodelist.item(0).getNodeName() + "="
+ databaseName);
} nodelist = theDocument.getElementsByTagName("UserName");
if (nodelist.getLength() > 0) {
userName = (nodelist.item(0)).getFirstChild().getNodeValue();
System.out.println(nodelist.item(0).getNodeName() + "="
+ userName);
} nodelist = theDocument.getElementsByTagName("Password");
if (nodelist.getLength() > 0) {
password = (nodelist.item(0)).getFirstChild().getNodeValue();
System.out.println(nodelist.item(0).getNodeName() + "="
+ password);
} } catch (Exception e) {
e.printStackTrace();
} } public static void main(String args[]) {
readDatabase1();
}}