我已经安装了tomcat服务器来处理eclipse Luna上的动态web项目。当我不使用任何项目文件加载它时,服务器似乎运行正常但是当我加载我的项目时它会出现错误“localhost上的服务器Tomcat v7.0服务器无法启动”。我检查了我的项目,似乎没有错误。这些是我得到的服务器启动消息:
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> WelcomeServlet in servlet mapping
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3325)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3300)
at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1438)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1357)
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:5419)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
答案 0 :(得分:0)
您对WelcomeServlet的url模式使用了错误的语法。设为bool Grid::is_available(int x, int y) const
{
if (x < 0 || x >= dim[1] || y < 0 || y >= dim[0])
throw std::invalid_argument(
"is_available(" + std::to_string(x) + ", "
+ std::to_string(y) + "): Invalid coordinate input.");
return occupancy[x][y] == AVAILABLE;
}
。我在Servlet的名称前添加了<url-pattern>/WelcomeServlet</url-pattern>
。
答案 1 :(得分:0)
Servlet映射可以通过两种方式定义:
<servlet-name>
for Named Servlets <url-pattern>
了解网址模式。使用servlet-name
<servlet-mapping> <servlet-name>WelcomeServlet</servlet-name> </servlet-mapping>
OR
使用url-pattern
<servlet-mapping> <url-pattern>/WelcomeServlet</url-pattern> </servlet-mapping>
如果您有兴趣了解 url-pattern 的规则,请参阅here