在一个项目中同时存在jsp和html两种页面,只需对springmvc配置做一点修改
1、maven引入freemarker依赖
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
2、修改spring配置文件
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/modules/"/>
</bean>
<!-- html视图解析 -->
<bean id="htmlViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
<property name="contentType" value="text/html; charset=utf-8"/>
<property name="suffix" value=".html"/>
<property name="order" value="0"/>
</bean>
<!-- jsp视图解析 -->
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/modules/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1"/>
</bean>
网友评论