Default html page for spring application

advertisements

I have a web application with url : localhost:8080/appname/views/welcome.html. So instead of typing the whole url, I want my application to open welcome.html when user types till localhost:8080/appname. So i have done the following changes in my spring config xml.

<mvc:annotation-driven />
<mvc:resources mapping="/static/**" location="/" />
<mvc:view-controller path="/" view-name="welcome" />
<mvc:default-servlet-handler />
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/views/" />
    <property name="suffix" value=".html" />
</bean>

but with this configuration, I am not able to bring my application up in browser instead getting 404 error.

need help on what I doing wrong.


You can do that by adding the following to your web.xml.

<welcome-file-list>
    <welcome-file>/views/welcome.html</welcome-file>
</welcome-file-list>