spring.jsp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <%@page contentType="text/html;charset=UTF-8"%>
  2. <%@page import="java.util.*"%>
  3. <%@page import="org.springframework.context.ApplicationContext"%>
  4. <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
  5. <html>
  6. <head>
  7. <meta charset="utf-8">
  8. <title>spring</title>
  9. <style>
  10. tbody tr:nth-child(odd) td,
  11. tbody tr:nth-child(odd) th {
  12. background-color: #f9f9f9;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <table border="1">
  18. <thead>
  19. <tr>
  20. <th>name</th>
  21. <th>type</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. <%
  26. ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(application);
  27. List<String> beanDefinitionNames = new ArrayList<String>(Arrays.asList(ctx.getBeanDefinitionNames()));
  28. Collections.sort(beanDefinitionNames);
  29. for (String name : beanDefinitionNames) {
  30. pageContext.setAttribute("name", name);
  31. pageContext.setAttribute("clz", ctx.getBean(name).getClass().getName());
  32. %>
  33. <tr>
  34. <td>${name}</td>
  35. <td>${clz}</td>
  36. </tr>
  37. <%
  38. }
  39. %>
  40. </tbody>
  41. </table>
  42. </body>
  43. </html>