问题描述
部署好项目后,启动tomcat,访问项目的某个servlet,出现了404错误,路径没写错,web.xml里面也没找到什么问题,查看控制台,发现如下信息,...严重: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webday13_session]]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 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: Invalid <url-pattern> logout in servlet mappingat org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3155)at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3130). . .at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)... 29 more2011-8-27 21:48:01 org.apache.catalina.startup.HostConfig deployDirectory严重: Error deploying web application directory webday13_sessionjava.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webday13_session]]at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:816)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787).at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)各位大侠,是哪里出了问题呢? 问题补充:访问路径:http://localhost:8080/webday13_session/countweb.xml如下:<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>CountServlet</servlet-name> <servlet-class>web.CountServlet</servlet-class> </servlet> <servlet> <servlet-name>LogoutServlet</servlet-name> <servlet-class>/web.LogoutServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CountServlet</servlet-name> <url-pattern>/count</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LogoutServlet</servlet-name> <url-pattern>logout</url-pattern> </servlet-mapping> </web-app>
解决方案
引用问题补充:freish 写道Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> logout in servlet mapping <servlet-mapping> <servlet-name>CountServlet</servlet-name> <url-pattern>/count</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LogoutServlet</servlet-name> <url-pattern>/logout</url-pattern> </servlet-mapping> logout的url-pattern前面记得加/,我看你后面把count前面的/又去掉了,都加上加上了,还是404错误。。。把错误信息再贴一下
解决方案二:
引用webday13_session是我的工程名,http://localhost:8080/webday13_session也访问不了你看一下tomcat下面的webapps有没有部署到你的工程,有没有你这个webday13_session文件夹。我估计你是部署在root文件夹下面你看看
解决方案三:
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> logout in servlet mapping <servlet-mapping> <servlet-name>CountServlet</servlet-name> <url-pattern>/count</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>LogoutServlet</servlet-name> <url-pattern>/logout</url-pattern> </servlet-mapping>logout的url-pattern前面记得加/,我看你后面把count前面的/又去掉了,都加上
解决方案四:
1,webday13_session是你的工程路径吧,你确定没有把程序放到webday13_session下? 检验一下 http://localhost:8080/webday13_session是否正确。2,进入了servlet里面没有 debug一下。
解决方案五:
<servlet-name>LogoutServlet</servlet-name> <servlet-class>/web.LogoutServlet</servlet-class> 不对
解决方案六:
把web.xml贴出来看看,是不是启动的时候就报错了呀
解决方案七:
把你web.xml贴出来 访问的路径也贴出来。