spring - How can i make a welcome page with a file which has .html extension -
hello new spring, trying create welcome file called index.html put index.html file under webapp folder. web xml file
<web-app id="webapp_id" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>spring4mvchelloworlddemo web application</display-name> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
and spring-servlet.xml file
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <context:component-scan base-package="com.websystique.springmvc" /> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/views/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> </beans>
when change index.html index.jsp , create index.jsp file works fine. question can`t make welcome page html extension ? if can mistake ?
<welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
you've configured internalresourceviewresolver
search files .jsp
suffix. in case, spring won't match index.html
.
you can replace suffix
value .html
if need match files under /web-inf/views/{viewname}.html
Comments
Post a Comment