import ....就不写了
public class ShowCategory  {

public void showCategory(){

} public Collection getCategory() throws ParserConfigurationException, SAXException, IOException {
Collection res = new ArrayList();
File dir = new File("./xml/", "Category.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(dir);
NodeList nodelist = doc.getElementsByTagName("Category");
for (int i = 0; i < nodelist.getLength(); i++) {
Element fatherElement = (Element) nodelist.item(i);
CategoryMethod category = new CategoryMethod();
category.setCategoryName(fatherElement.getAttribute("name"));
category.setFilename(fatherElement.getAttribute("filename"));
res.add(category);
}
return res;
}
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
ShowCategory show = new ShowCategory();
Collection categorys = show.getCategory();
Iterator it = categorys.iterator();
while(it.hasNext()){
Category temp = (Category)it.next();
System.out.println(temp.getCategoryName());
System.out.println(temp.getFilename());
}
//System.out.print(show.getCategory());
}
}这个程序可以运行成功输出结果但放到JSP网页上<jsp:useBean class="xml.ShowCategory" id="showCategory" scope="session">
<%
Collection categorys = showCategory.getCategory();
Iterator it = categorys.iterator();
while(it.hasNext()){
Category temp = (Category)it.next();
out.println(temp);
}%>
<jsp:useBean>就出现错误了:
type Status reportmessage F:\Tomcat 5.0\bin\.\xml\Category.xml (系统找不到指定的路径。)description The requested resource (F:\Tomcat 5.0\bin\.\xml\Category.xml (系统找不到指定的路径。)) is not available.
这个路径问题怎么搞啊!高手们,帮帮我啊!