spring boot 页面获取应用程序路径
来源:互联网 发布:python无参函数 编辑:程序博客网 时间:2024/06/06 01:59
1 定义拦截器:
public class PageContextInterceptor implements HandlerInterceptor{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
request.setAttribute("ctx", "http://"+request.getRemoteHost()+":"+request.getLocalPort()+"/spring-boot-fm");
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
}
}
2 拦截器加入applicationContext.xml
<mvc:interceptors>
<bean class="com.dynastqin.springboot.cfg.PageContextInterceptor" />
</mvc:interceptors>
3 spring boot启动加载spring-xx.xml配置:
@ImportResource({ "classpath:spring-ctx.xml"})
@SpringBootApplication
public class SpringfreemarkerApplication {
4 页面使用:
<link rel="stylesheet" href="${ctx}/css/bootstrap.min.css" />
<form name="employee" action="${ctx}/addEmployee" method="post">
拓展阅读:
spring boot 启动sevlet配置
0 0
- spring boot 页面获取应用程序路径
- Hello Spring Boot应用程序
- Spring Boot应用程序启动器
- spring boot 路径 整理
- spring boot 静态路径
- spring boot + html 页面
- spring-boot跳转页面
- 获取应用程序自身路径
- 获取当前应用程序路径
- 获取应用程序路径
- C#获取应用程序路径
- 获取应用程序当前路径
- VC获取应用程序路径
- 获取应用程序系统路径
- 获取应用程序路径
- VC获取应用程序路径
- 获取应用程序路径信息
- 获取应用程序的路径
- 安卓开机流程
- UVa489刽子手的游戏
- iOS之富文本
- SpoolDirectorySource使用及源码分析
- iOS常见的手势
- spring boot 页面获取应用程序路径
- 优先队列
- appStore_审核指南
- 内部类
- 链表
- 第一次写博客
- android 五大布局
- 其它书籍笔记
- Linux进程管理之SMP负载平衡