web.xml配置的问题
程序运行出错
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>seventh</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>RegisterAction</display-name>
<servlet-name>RegisterAction</servlet-name>
<servlet-class>com.henu.service.RegisterAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegisterAction</servlet-name>
<url-pattern>/RegisterAction</url-pattern>
</servlet-mapping>
</web-app>
console:
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log信息: Server version: Apache Tomcat/7.0.68
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Feb 8 2016 20:25:54 UTC
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.68.0
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 7
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 6.1
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files\Java\jre1.8.0_66
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_66-b18
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: C:\tomcat\apache-tomcat-7.0.68
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: C:\tomcat\apache-tomcat-7.0.68
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=C:\tomcat\apache-tomcat-7.0.68
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:\tomcat\apache-tomcat-7.0.68
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=C:\tomcat\apache-tomcat-7.0.68\wtpwebapps
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:\tomcat\apache-tomcat-7.0.68\endorsed
四月 25, 2016 6:51:49 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
四月 25, 2016 6:51:49 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
四月 25, 2016 6:51:49 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
四月 25, 2016 6:51:50 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)
四月 25, 2016 6:51:50 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-8080"]
四月 25, 2016 6:51:50 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
四月 25, 2016 6:51:50 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1518 ms
四月 25, 2016 6:51:50 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
四月 25, 2016 6:51:50 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.68
四月 25, 2016 6:51:50 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor C:\tomcat\apache-tomcat-7.0.68\conf\Catalina\localhost\seventh.xml
四月 25, 2016 6:51:50 下午 org.apache.catalina.startup.SetContextPropertiesRule begin
警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:seventh' did not find a matching property.
四月 25, 2016 6:51:50 下午 org.apache.catalina.core.ContainerBase addChildInternal
严重: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/seventh]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1962)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: The servlets named [RegisterAction] and [com.henu.service.RegisterAction] are both mapped to the url-pattern [/RegisterAction] which is not permitted
at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:293)
at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2462)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2137)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2098)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2090)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2090)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2090)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1304)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5472)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 10 more
四月 25, 2016 6:51:50 下午 org.apache.catalina.startup.HostConfig deployDescriptor
严重: Error deploying configuration descriptor C:\tomcat\apache-tomcat-7.0.68\conf\Catalina\localhost\seventh.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/seventh]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1962)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
四月 25, 2016 6:51:50 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deployment of configuration descriptor C:\tomcat\apache-tomcat-7.0.68\conf\Catalina\localhost\seventh.xml has finished in 301 ms
四月 25, 2016 6:51:50 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\docs
四月 25, 2016 6:51:51 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [184] milliseconds.
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\docs has finished in 397 ms
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\examples
四月 25, 2016 6:51:51 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
四月 25, 2016 6:51:51 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
四月 25, 2016 6:51:51 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@3e38d94f')
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\examples has finished in 384 ms
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\host-manager
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\host-manager has finished in 76 ms
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\manager
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\manager has finished in 102 ms
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\ROOT
四月 25, 2016 6:51:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory C:\tomcat\apache-tomcat-7.0.68\webapps\ROOT has finished in 62 ms
四月 25, 2016 6:51:51 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-8080"]
四月 25, 2016 6:51:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
四月 25, 2016 6:51:52 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 1404 ms
回答:
你这个web.xml是全部的吗,错误其实已经打出来了,The servlets named [RegisterAction] and [com.henu.service.RegisterAction] are both mapped to the url-pattern [/RegisterAction] which is not permitted。 如果web.xml中没有多个servlet匹配同一个url-pattern,那么就有可能在RegisterAction中使用了注解。 你可以看一下。
回答:
1、检查Servlet配置:类全名有木有写错;
2、检查提交表单的action属性的值,是否和Servlet的url-pattern
属性一致;
3、检查是否同时使用XML和注解的方式配置同一个Servlet类;
4、检查浏览器的URL;
回答:
原来是因为这个。。。去掉就好了
可以看看这个http://haohaoxuexi.iteye.com/blog/2013691
以上是 web.xml配置的问题 的全部内容, 来源链接: utcz.com/a/166993.html