gpt4 book ai didi

java - Tomcat 7 中 servlet 映射中的 null 无效

转载 作者:行者123 更新时间:2023-12-01 11:22:30 25 4
gpt4 key购买 nike

我知道我遵循了 servlet 映射规范,并且还使用 Netbeans 7.0 创建了 servlet。

这是我的 web.xml

<servlet>
<servlet-name>Selection</servlet-name>
<servlet-class>com.package.sample.Selection</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Selection</servlet-name>
<url-patern>/Selection</url-patern>
</servlet-mapping>

关于 Catalina 日志文件

SEVERE: Error deploying web application directory client java.lang.IllegalArgumentException: Invalid null in servlet mapping at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3155) 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:1350) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:316) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 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:1322) 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:89) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324) 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:145) 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:145) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.startup.Catalina.start(Catalina.java:620) 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:303) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) 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.tanukisoftware.wrapper.WrapperStartStopApp.run(WrapperStartStopApp.java:264) at java.lang.Thread.run(Thread.java:662)

最佳答案

xml 文件中 pattern 的拼写错误。

<servlet>
<servlet-name>Selection</servlet-name>
<servlet-class>com.package.sample.Selection</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Selection</servlet-name>
<url-pattern>/Selection</url-pattern>
</servlet-mapping>

关于java - Tomcat 7 中 servlet 映射中的 <url-pattern> null 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31072245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com