package com.deitel.advjhtp1.servlets;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
public class WelcomeServlet2 {
public WelcomeServlet2() {
}
public static void main(String[] args) {
Document doc;
Element root;
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
factory.setValidating(true);
try{
DocumentBuilder builder=factory.newDocumentBuilder();
doc=builder.newDocument();
}catch(ParserConfigurationException pce)
{
pce.printStackTrace();
}
root=doc.createElement("result");
}
}
还是提示: root=doc.createElement("result");这句话错误
"WelcomeServlet2.java": Error #: 553 : variable doc might not have been initialized at line 24, column 10
原帖来自于网易社区:
http://p5.club.163.com/viewArticleByWWW.m?boardId=java&articleId=java_107a8e37bc7341e