2013-02-14 78 views
1

当我被要求解决问题时,通过理解代码流,我找到了被击中的URL,然后我转到映射到该控制器的那个控制器特定的URL如何在弹簧注释中找到映射到URL的控制器

我觉得过程very tedious,因为我们有一些50控制器类和多个方法标注了网址,里面

现在,我使用Eclipse IDE中搜索选项,并找到注释的方法URL模式

有什么简单的方法,我可以得到像URL这样的信息映射到什么样的方式在某某类?

如果你正在使用Spring MVC的3.X结帐链接请帮我在这

+1

我常想,这是基于注释的Web编程的缺点。我喜欢我的单个XML配置文件,至少对于非重要的控制器分组。 – dbreaux 2013-02-14 14:10:35

回答

3
+0

有没有关于如何在项目中使用它的示例? – Arun 2013-02-18 08:09:03

+1

https://github.com/rstoyanchev/spring-mvc-31-demo.git – 2013-02-18 08:28:17

+0

for spring 3.0有没有什么办法可以实现这个?类** RequestMappingHandlerMapping **仅从3.1开始。如何在3.0中实现相同? – Arun 2013-02-27 11:13:59

1

也许Reflections库可以帮助:

Reflections reflections = new Reflections("my.package", 
     new TypeAnnotationsScanner(), new MethodAnnotationsScanner()); 

Set<Class<?>> controllers = reflections.getTypesAnnotatedWith(Controller.class); 

Set<Method> requestMappings = reflections.getMethodsAnnotatedWith(RequestMapping.class);