log4jdbc.jsp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <%@page contentType="text/html;charset=UTF-8"%>
  2. <%@page import="org.springframework.context.ApplicationContext"%>
  3. <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
  4. <%@page import="com.mossle.core.jdbc.DataSourceService"%>
  5. <%
  6. ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(application);
  7. DataSourceService dataSourceService = (DataSourceService) ctx.getBean("dataSourceService");
  8. if (request.getParameter("toggle") != null) {
  9. if (dataSourceService.isLog4jdbcEnabled()) {
  10. dataSourceService.disableLog4jdbc();
  11. } else {
  12. dataSourceService.enableLog4jdbc();
  13. }
  14. response.sendRedirect("log4jdbc.jsp");
  15. }
  16. pageContext.setAttribute("dataSourceService", dataSourceService);
  17. %>
  18. <html>
  19. <head>
  20. <meta charset="utf-8">
  21. <title>log4jdbc</title>
  22. <style>
  23. tbody tr:nth-child(odd) td,
  24. tbody tr:nth-child(odd) th {
  25. background-color: #f9f9f9;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <table border="1">
  31. <tbody>
  32. <tr>
  33. <td>状态</td>
  34. <td>${dataSourceService.log4jdbcEnabled}</td>
  35. <td><button onclick="location.href='log4jdbc.jsp?toggle=true'">${dataSourceService.log4jdbcEnabled ? '禁用' : '启用'}</button></td>
  36. </tr>
  37. </tbody>
  38. </table>
  39. </body>
  40. </html>