我想配置Spring只使用我的html文件,而不是jsp視圖解析器,但無法讓它工作。我嘗試了很多不同的配置,並且我只想在每次輸入localhost:8080 /時重定向到/WEB-INF/views/index.html。現在我在我的tomcat控制檯:沒有視圖解析器,但純html的彈簧
org.springframework.web.servlet.PageNotFound - 未找到 HTTP請求的URI與[/WEB-INF/views/index.html]在DispatcherServlet的 映射名稱爲'appServlet'。
這裏是我的servlet-context.xml
snippet。
<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>
現在我有'警告:org.springframework.web.servlet.PageNotFound - 沒有在DispatcherServlet的發現HTTP請求的URI與[/]名爲「映射appServlet'' :( – xwhyz
@xwhyz什麼網址是'DispatcherServlet'映射到?當你在它只是發佈你的完整配置 –
編輯我的問題 – xwhyz