<!-- config Freemarker View Resolver--> <bean id="viewResolver" 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="cache" value="true"/> <property name="suffix" value=".ftl"/> <property name="order" value="0"/> <property name="requestContextAttribute" value="request"/> </bean>
2. 在ftl文件中使用request
<#assign ctx=request.getContextPath()>