找不到 Index.html 的映射

No mapping found for Index.html

考虑以下 Controller

@Controller
public class HomeController {

@RequestMapping(value="/")
public ModelAndView home() {
    ModelAndView model = new ModelAndView("index");
    return model;
}

这是我的 servlet-context.xml:

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".html" />
</bean>

这是我的 web.xml:

<!-- 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>

每次我点击 url 我都会收到这条消息:

Aug 08, 2015 10:59:47 PM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/MeraComputer/WEB-INF/views/index.html] in DispatcherServlet with name 'appServlet' Aug 08, 2015 10:59:48 PM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/MeraComputer/WEB-INF/views/index.html] in DispatcherServlet with name 'appServlet'

我想我的文件夹结构也不错,

Folder Structure

我认为静态 html 文件不能用作视图。请求正在 转发 到视图,即 /MeraComputer/WEB-INF/views/index.html,因为它是静态文件而不是请求处理程序,您可能会收到警告。

静态文件应该以不同的方式处理。 This is 类似的 post,我认为,这可能有所帮助。