springMVC配置html和jsp檢視

落地僧發表於2016-04-07
	<!-- velocity檢視解析器 -->
	<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
		<!-- 每個頁面都引用 -->
		<property name="exposeRequestAttributes" value="true" />
		<!-- 頁面型別 -->
		<property name="contentType" value="text/html;charset=UTF-8" />
		<!-- 字首 -->
		<property name="prefix" value="" />
		<!-- 字尾 -->
		<property name="suffix" value=".html" />
		<!-- 每個頁面都引用 -->
		<property name="layoutUrl" value="layout.html" />
		<!-- 當前專案域名(IP)加埠號,html頁面引用${rc.contextPath}-->
		<property name="requestContextAttribute" value="rc" />
		<!--第一個匹配的是freemarker的檢視解析器,如果匹配不成功,則自動選擇order=1的其他解析器-->
		<property name="order" value="0" />
	</bean>
	<bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
		<property name="resourceLoaderPath">
			<value>WEB-INF/pages</value>
		</property>
		<property name="velocityProperties">
			<props>
				<prop key="input.encoding">UTF-8</prop>
				<prop key="output.encoding">UTF-8</prop>
				<prop key="contentType">text/html;charset=UTF-8</prop>
			</props>
		</property>
	</bean>
	<!--jsp檢視解析器 -->
	<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/" />
		<property name="suffix" value=".jsp" />
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        	<property name="order" value="1" />
	</bean> 


ps:在專案中配置時在做進一步優化

相關文章