项目随笔之springmvc中freemark如何获取项目路径
2024-08-30 22:24:07
转载:http://blog.csdn.net/whatlookingfor/article/details/51538995
在SpringMVC框架中使用Freemarker试图时,要获取根路径的方式如下:
<!-- FreeMarker视图解析 如返回userinfo。。在这里配置后缀名ftl和视图解析器。。 -->
<bean id="viewResolverFtl"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
<property name="suffix" value=".ftl" />
<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="request" />
<property name="cache" value="true" />
<property name="order" value="0" />
</bean>
其中property name=”requestContextAttribute” value=”request”是关键。
意思是把Spring的RequestContext对象暴露为变量request
利用${request.contextPath}来获取应用程序的contextPath
最新文章
- BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 [后缀数组]
- react-native-http请求后navigator导航跳转
- oracle判断字段是否存在语句
- 360极速浏览器安装.crx扩展(postman)
- [代码片段]OSTU算法
- P3384: [Usaco2004 Nov]Apple Catching 接苹果
- URL伪静态设置 (apache2.4)
- NYOJ 58 步数最少 【BFS】
- c++内存流
- 阿里云正式上线移动直播问答解决方案,助力APP尽情“撒币”!
- JAVA进阶18
- messageQ 消息队列
- whil
- rabbitmq系统学习(一)
- Nginx安装及配置详解【转】
- ubuntu输入法
- 英文写作指南——《“compare to”等同“compare with”吗?》
- DIM-00014: Cannot open the Windows NT Service Control Manager.
- Python中sorted()方法的用法
- 为什么子元素设置margin-top会作用在父元素上?