1. 程式人生 > >springMVC 配置預設首頁

springMVC 配置預設首頁

spring的配置檔案

<mvc:view-controller path="/" view-name="index"/>
<bean id="viewResolver"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
		<property name="suffix" value=".ftl"></property>
		<property name="contentType" value="text/html;charset=utf-8"></property>
	</bean>

	<!-- 配置Freemarker -->
	<bean id="freemarkerConfigurer"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<property name="templateLoaderPath" value="/WEB-INF/ftl/" />
		
	</bean>


我是使用freemarker, 

jsp也差不多

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
</bean>