¹ØÓÚxmlµÄ²Ù×÷£¬Java±¨xmlÎļþ²»´æÔڵĴíÎó ¼±£¡
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db=dbf.newDocumentBuilder();
File fl=new File("d:/xml/userdatabase.xml");
doc =db.parse(fl);
Element root=(Element)doc.getElementsByTagName("database").item(0);
NodeList nl=root.getElementsByTagName("user");
ÉÏÊöµÚËÄÐУ¬±¨Õâ¸ö´í£¬DÅÌϵÄÎļþÊÇ´æÔÚµÄ £¬²»½â £¿Çë¸ßÊÖÖ¸µã
Exception in thread "main" java.io.FileNotFoundException: d:\xml\userdatabase.xml (Ö¸¶¨¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬見¤Ä¤«¤ê¤Þ¤»¤ó¡£)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream. <init>(FileInputStream.java:106)
at java.io.FileInputStream. <init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:184)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
Ïà¹ØÎÊ´ð£º
ÎÒÔÚjspÒ³Ãæ´æÉÏÒ»¸ösession,±¾Ò³Ã滹¿ÉÒÔÈ¡³öÖµÀ´.
µ«ÊÇһˢÐÂ,»òÕß´ò¿ªÐµÄÒ³Ãæ¾ÍÈ¡²»³öÖµÀ´ÁË.
Ææ¹ÖµÄÊÇ,ÎÒ²âÊÔÁíÒ»¸ö³ÌÐòʱºò
ÔÚjspÒ³Ãæ´æÉÏÒ»¸ösession,±¾Ò³Ãæ¿ÉÒÔÈ¡³öÖµÀ´,ˢлò´ò¿ªÐÂÒ³ÃæÖµÄÜÈ¡³öÀ´ÁË.
......
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......
ÎÒµÄjava applet ǶÈëhtmlºóÎÞ·¨ÏÔʾ£¬¶øÓÃappletviewerÏÔʾÕý³£ÎªÊ²Ã´£¬»¹ÓоÍÊÇÓÃhtml converterת»¯ºó¿ÉÒÔÏÔʾ£¬ÎªÊ²Ã´£¿Çë´óÏÀ´Í½Ì£¡
HTML code:
<HTML>
<HEAD>
<TITLE>TEST.HTML< ......