查看: 1926|回复: 0

[Java学习] spring mvc 获取所有url

发表于 2016-5-14 11:26:43
太阳http代理AD
<无详细内容>
  1. @Controller
  2. public class IndexController {
  3. /*@Autowired
  4. private RequestMappingHandlerMapping RequestMappingHandlerMapping;*/
  5. @RequestMapping("/")
  6. public String index(HttpServletRequest request) {
  7. WebApplicationContext wc = (WebApplicationContext) request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
  8. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping bean = wc.getBean(RequestMappingHandlerMapping.class);
  9. Map<RequestMappingInfo, HandlerMethod> handlerMethods = bean.getHandlerMethods();
  10. request.setAttribute("url", handlerMethods);
  11. return "index";
  12. }
  13. }
复制代码


太阳http代理AD
回复

使用道具 举报