【发布时间】:2014-01-10 08:05:51
【问题描述】:
我正在尝试将 Spring 配置为仅使用我的 html 文件而不是 jsp 视图解析器,但无法使其工作。我尝试了许多不同的配置,我只想在每次输入 localhost:8080/ 时重定向到 /WEB-INF/views/index.html。现在我在我的 tomcat 控制台中拥有的是:
org.springframework.web.servlet.PageNotFound - 找不到映射 DispatcherServlet 中带有 URI [/WEB-INF/views/index.html] 的 HTTP 请求 名称为“appServlet”。
这是我的servlet-context.xmlsn-p。
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="WEB-INF/views/" />
<beans:property name="suffix" value="" />
</beans:bean>
<view-controller path="/" view-name="index.html"/>
任何建议我缺少什么?
编辑- web.xml:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/WEB-INF/views/index.html</welcome-file>
</welcome-file-list>
【问题讨论】:
标签: java spring spring-mvc