jsp调用web-inf下的类报错

来源:百度知道 编辑:UC知道 时间:2024/05/05 16:58:29
在D:\Program Files\Tomcat 6.0\webapps\myweb\WEB-INF\classes\myclass放置了CreateXLS.class文件,原java文件内容如下:

package myclass;

import java.io.*;
import jxl.*;
import jxl.write.*;
public class CreateXLS
{
public void crxls(String path){
try{
WritableWorkbook book= Workbook.createWorkbook(new File(path));
WritableSheet sheet=book.createSheet("第一页",0);
jxl.write.Number number = new jxl.write.Number(1,0,789.123);
sheet.addCell(number);
//写入数据并关闭文件
book.write();
book.close();
}catch(Exception e){
System.out.println(e);
}
}

public static void main(String args[])
{
CreateXLS vl=new CreateXLS();
vl.crxls("1.xls");
}
}
在D:\Program Files\Tomcat 6.0\webapps\myweb放置了jsp文件,内容如下:

<%@ page contentType="text/html; charset=gb2312" language=

NoClassDefFoundError
提示找不到CLASS文件,
然后,你的JAVA文件是个JAVABEAN,而不是SERVLET,你的WEB-INF/web.xml文件里无需配置,而且web.xml一担配置错误,程序就无法运行.
如果,你只是想要运行你上面的一个例子的话,请把网站根目录下的WEB-INF/web.xml文件里的内容改成
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Lice