1. 程式人生 > >springmvc結合freemarker配置url訪問的根路徑

springmvc結合freemarker配置url訪問的根路徑

轉自:http://blog.csdn.net/suyu_yuan

<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerSettings" ref="freemarkerConfiguration" />
<property name="templateLoaderPath">
<value>/WEB-INF/htmlFolder/</value>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"></property>
<property name="prefix" value="" />
<property name="suffix" value=".jsp" />
<property name="contentType" value="text/html;charset=utf-8" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="requestContextAttribute" value="ctx"></property>
</bean>

@Controller
@RequestMapping(value = "/")
public class IndexController {


@RequestMapping(value = "/login", method = RequestMethod.GET)
protected String login() {


return "login";//訪問/WEB-INF/htmlFolder/下的login.jsp頁面
}

}