SpringMVC 中获取所有的路由配置。
ApplicationContext context = TMSContextLookup.getApplicationContext();
String[] controllerList = context.getBeanNamesForAnnotation(Controller.class);
for(String name : controllerList){
try {
Object bean = context.getBean(name);
String preFix = "";
RequestMapping clazzRequestMapping = bean.getClass().getAnnotation(RequestMapping.class);
if (clazzRequestMapping!=null && !TMSUtil.isEmpty(clazzRequestMapping.value())){
preFix = clazzRequestMapping.value()[0];
}
Method[] method = bean.getClass().getDeclaredMethods();
if (method!=null){
for (Method m :method){
RequestMapping mRequestMapping = m.getAnnotation(RequestMapping.class);
if (mRequestMapping!=null && !TMSUtil.isEmpty(mRequestMapping.value())){
String path = mRequestMapping.value()[0];
System.out.println(preFix + "/" + path);
}
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}
}
SpringMVC 中获取所有的路由配置。的更多相关文章
- springMVC中获取request和response对象的几种方式(RequestContextHolder)
springMVC中获取request和response对象的几种方式 1.最简单方式:参数 2.加入监听器,然后在代码里面获取 原文链接:https://blog.csdn.net/weixin_4 ...
- 在过滤器中获取在web.xml配置的初始化参数
在过滤器中获取在web.xml配置的初始化参数 例如 <filter> <filter-name>cross-origin</filter-name> < ...
- 在Springmvc中获取properties属性
一些关键的属性一般都会拿出来作为配置,比如数据库连接等.在springmvc中也提供了获取property的类,比如@Value来获取.我接触spring很浅,基本上都是百度的问题解决方法,百度到@v ...
- 在SpringMVC中获取request对象
1.注解法 @Autowired private HttpServletRequest request; 2. 在web.xml中配置一个监听 <listener> <listen ...
- 在SpringMVC中获取request对象的几种方式
1.最简单的方式(注解法) @Autowired private HttpServletRequest request; 2.最麻烦的方法 a. 在web.xml中配置一个监听 <listene ...
- springmvc中获取request对象,加载biz(service)的方法
获取request对象: 首先配置web.xml文件--> <listener> <listener-class> org.springframework.web.con ...
- SpringMvc中获取Request
Controller中加参数 @Controller public class TestController { @RequestMapping("/test") public v ...
- 如何在SpringMVC中获取request对象
1.注解法 @Autowired private HttpServletRequest request; <listener> <listener-class> org.spr ...
- 不用@Value从Spring的ApplicationContext中获取一个或全部配置
获取一个配置: applicationContext.getEnvironment().resolvePlaceholders("${propertyKey}"); // 方法1 ...
随机推荐
- 读javascript高级程序设计11-事件
一.事件流 事件流指从页面中接收事件的顺序. 1.事件冒泡(常用) IE中采用的事件流是事件冒泡,先从具体的接收元素,然后逐步向上传播到不具体的元素. 2.事件捕获(少用) Netscapte采用事件 ...
- NSComparisonResul、NSNotFound、NSEnumerationOptions......的用处
NSNotFound 定义一个值,用于指示请求项找不到或不存在.Defines a value that indicates that an item requested couldn’t be fo ...
- Topcoder SRM584 DIV 2 500
#include <set> #include <iostream> #include <string> #include <vector> using ...
- [强连通分量] POJ 2186 Popular Cows
Popular Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 31815 Accepted: 12927 De ...
- Linux在目录中查找某个函数
1,在某个路径下查文件. 在/etc下查找“*.log”的文件 find /etc -name “*.log” 2,扩展,列出某个路径下所有文件,包括子目录. find /etc -name “*” ...
- java编码转换 unicode to utf-8
private String decodeUnicode(String theString) { char aChar; int len = theString.length(); StringBuf ...
- Hadoop生态上几个技术的关系与区别:hive、pig、hbase 关系与区别
初接触Hadoop技术的朋友肯定会对它体系下寄生的个个开源项目糊涂了,我敢保证Hive,Pig,HBase这些开源技术会把你搞的有些糊涂,不要紧糊涂的不止你一个,如某个菜鸟的帖子的疑问,when to ...
- WCF服务开发与调用的完整示例
WCF服务开发与调用的完整示例 开发工具:VS2008 开发语言:C# 开发内容:简单的权限管理系统 第一步.建立WCF服务库 点击确定,将建立一个WCF 服务库示例程序,自动生成一个包括IServi ...
- php大力力 [044节] PHP的POST语句一定要大写!!if(!empty($_POST['id'])) {
早上花了几个小时,寻找错误!!! 不应该这样写 if(!empty($_Post['id'])) { 应该这样写 if(!empty($_POST['id'])) { 万万不能小谢!
- Struts2之过滤器和拦截器的区别
刚学习Struts2这个框架不久,心中依然有一个疑惑未解那就是过滤器和拦截器的区别,相信也有不少人跟我一样对于这个问题没有太多的深入了解 那么下面我们就一起来探讨探讨 过滤器,是在java web中, ...