Tomcat 部署文件出现问题 50
helloServlet.java:importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;im...
helloServlet.java:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.sang.pack.*;
public class helloServlet extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
out.println(docType+"<html><head></head><body>HELLO"+(new number().a)+"</body></html>");
}
}
com/sang/pack/number.java:
package com.sang.pack;
public class number{
public int a = 100;
}
将helloServlet.java编译后,放入到tomcat当中
结构如下:
webapps
-ROOT
--WEB-INF
---classes
----helloServlet.class
----com
-----sang
------pack
-------number.class
但在启动后 提示NoClassDefFoundError: com/sang/pack/number 展开
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.sang.pack.*;
public class helloServlet extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
out.println(docType+"<html><head></head><body>HELLO"+(new number().a)+"</body></html>");
}
}
com/sang/pack/number.java:
package com.sang.pack;
public class number{
public int a = 100;
}
将helloServlet.java编译后,放入到tomcat当中
结构如下:
webapps
-ROOT
--WEB-INF
---classes
----helloServlet.class
----com
-----sang
------pack
-------number.class
但在启动后 提示NoClassDefFoundError: com/sang/pack/number 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询