【发布时间】:2015-07-11 04:39:00
【问题描述】:
我的代码在github
https://github.com/shiblybcc/blog-aggregator
我刚刚创建了一个 spring 框架项目。这是我的 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"
version="3.0">
<display-name>Course Rating</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
在我运行我的码头服务器后,它完美运行并显示了 index.jsp 文件的内容。但是如果我在 web.xml 文件中添加以下代码
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
<url-pattern>*.htm</url-pattern>
<url-pattern>*.json</url-pattern>
<url-pattern>*.xml</url-pattern>
</servlet-mapping>
我得到了错误
HTTP ERROR: 503
Problem accessing /. Reason:
Service Unavailable
我正在学习一个教程,他们也在做同样的事情。我不明白我的代码有什么问题。提前致谢。
【问题讨论】:
-
添加后能否查看:
dispatcher / -
这也行不通
-
你访问的是什么网址?
-
您能否确认在应用程序部署期间没有错误(在日志/控制台中)?
标签: java spring web.xml url-pattern