嗨朋友们,在这种情况下,出于安全目的,我必须限制使用来自 url 的链接的直接访问,我需要相同的代码来完成这个过程,任何人都可以帮助我。在此过程中,将涉及两个用户(管理员和用户)。
只是我试过这个。但不工作
<security-role><role-name>admin</role-name></security-role>
<security-role><role-name>user</role-name></security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>User</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>