javabean程序测试通过放到网页上就不行了!!!!

zhangbo999 2006-11-07 07:06:45
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 report

message F:\Tomcat 5.0\bin\.\xml\Category.xml (系统找不到指定的路径。)

description The requested resource (F:\Tomcat 5.0\bin\.\xml\Category.xml (系统找不到指定的路径。)) is not available.


这个路径问题怎么搞啊!高手们,帮帮我啊!
...全文
244 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangbo999 2006-11-07
  • 打赏
  • 举报
回复
解决了,设置一个web应用路径传进javabean
  • 打赏
  • 举报
回复
WEB应用路径的问题需要考虑上下文
在设置文件路径的时候 考虑ContextPath
zhangbo999 2006-11-07
  • 打赏
  • 举报
回复
达人们,快来帮帮我啊!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧