通常我们通过配置文件的前缀来进行配置跳转界面的类型,但是通常我们项目可能有jsp与html,如何保证能够既能跳转jsp又能跳转html,我们只需要修改配置文件就能满足这个功能.
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerSettings">
<bean
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="default_encoding">utf-8</prop>
<prop key="output_encoding">utf-8</prop>
</props>
</property>
</bean>
</property>
<property name="templateLoaderPath">
<value>/WEB-INF/views</value>
</property>
</bean>
<bean id="htmlviewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix" value=".html" />
<property name="order" value="0"></property>
<property name="contentType" value="text/html;charset=UTF-8"></property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="viewClass" value="org.springframework.web.servlet.view.InternalResourceView"/> <!-- 不能用jstl的那个 -->
<property name="contentType" value="text/html;charset=UTF-8"/>
<property name="order" value="0"></property>
</bean>