switchUser.jsp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <%@page contentType="text/html;charset=UTF-8"%>
  2. <%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
  3. <%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
  4. <%pageContext.setAttribute("ctx", request.getContextPath());%>
  5. <html>
  6. <head>
  7. <meta charset="utf-8">
  8. <title>switchUser</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. <script type="text/javascript">
  16. function switchUser() {
  17. var name = prompt("请输入要切换的用户名", "");
  18. if (name != null && name != "") {
  19. window.location.href = "${ctx}/j_spring_security_switch_user?j_username=" + name;
  20. }
  21. }
  22. </script>
  23. </head>
  24. <body>
  25. <div align="center">
  26. <tags:hasPerm value="util,ROLE_PREVIOUS_ADMINISTRATOR">
  27. <a href="#" onclick="switchUser()">切换用户</a>
  28. </tags:hasPerm>
  29. <sec:authorize ifAnyGranted="ROLE_PREVIOUS_ADMINISTRATOR">
  30. <a href="${ctx}/j_spring_security_exit_user">退出切换用户</a>
  31. </sec:authorize>
  32. <ul>
  33. <li>当前用户:<sec:authentication property="name" /></li>
  34. <li>是否模拟用户:
  35. <sec:authorize ifAnyGranted="ROLE_PREVIOUS_ADMINISTRATOR">
  36. </sec:authorize>
  37. <sec:authorize ifNotGranted="ROLE_PREVIOUS_ADMINISTRATOR">
  38. </sec:authorize>
  39. </li>
  40. </ul>
  41. </div>
  42. </body>
  43. </html>