How to map a html page in Spring MVC

1

I have a Spring MVC project that will provide the rest service for the front end. But when creating a page .html the project does not recognize it and always 404. Does there any configuration that I should do more for spring mvc to recognize .html?

servlet-context.xml file:

<beans:bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" /> /*ja mudei para .html mas não funcionou*/
</beans:bean>

And the web.xml file:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<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>
    
asked by anonymous 18.08.2016 / 01:19

1 answer

0

You do not have to add the .html extension in the InternalResourceViewResolver setting of Spring because it is used to render files that need rendering engines like the JSP, in which case the configuration you need to add is this :

<mvc:resources mapping="/meusArquivosAssets/**" location="/meusArquivosAssets/" />
    
16.09.2016 / 14:01