Java Web 开发错误解决办法

今天我用了近一天的时间研究一个错误,早上写代码是遇到一个 错误严重错误代码如下:
严重: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/201110181]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1055)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:978)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1329)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:389)
	at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:334)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:621)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name fDemoServlet
	at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3151)
	at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3130)
	at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1301)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1390)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	... 29 more
2011-10-18 15:21:19 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory 201110181
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/201110181]]
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:816)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1055)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:978)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1329)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:389)
	at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:334)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:621)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)


错误分别是 :

                    org.apache.catalina.LifecycleException:

                     java.lang.IllegalArgumentException:

                     java.lang.IllegalStateException:

       这三个错误原来见过,但是没有记住,今天让这三个错误纠结了我一天 现在我将错误的产生的原因给大家做个总结

现在正在学习 Servlet 我建立了三个文件 第一个文件Java文件

通过 New ----> Servlet 创建的 DemoServlet.java

package cn.cdn.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DemoServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		/*设置编码*/
		request.setCharacterEncoding("UTF-8");
		System.out.println("==========-----------=============");
		
	}

}


 然后生成的 xml :web.xml



  
  
    This is the description of my J2EE component
    This is the display name of my J2EE component
    DemoServlet
    cn.cdn.web.servlet.DemoServlet
  

  
    DemoServlet//如果这里的名字定义错误 就会出现上面的错误!
    /demo.do
   	
  
    index.jsp
  

原因很简单,就是名字他找不到,所以就会报错,至于怎么解释我不清楚总之如果遇到这个错误大家就去这个地方找就行了

 

web.xml 中的 DemoServlet

                      /demo.do

看看是不是能解决!


 

==============================================================

需要帮助请加QQ:284651035 (本博主) 

博主微博:http://weibo.com/cnbailu (白璐同学) 

                   http://weibo.com/u/2717396075(美女笑话精选)

陈老师微博:http://weibo.com/redarmychen Java 方向

李老师微博:http://weibo.com/csdnliwei PHP方向

移动(手机)软件开发交流群: 57636364  (申请请注明:是在CSDN博客看到的,进入群后记得改名片)谢谢!


你可能感兴趣的:(java,web,servlet,application,encoding,class)