spring security是否能控制到按钮?能够介绍一下

解决方案 »

  1.   


    <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %><sec:authorize ifAllGranted="ROLE_SUPERVISOR">
      <form method="GET" action="<c:url value="/addVisit.do"/>" name="formVisitPet${pet.id}">
          <input type="button" name="button"/>
          <input type="hidden" name="petId" value="${pet.id}"/>
          <p class="submit"><input type="submit" value="Add Visit"/></p>  </form>
    </sec:authorize>
    这样是控制页面是否显示特定的组件
    <bean id="bankManagerSecurity" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
      <property name="validateConfigAttributes"><value>true</value></property>
      <property name="authenticationManager"><ref bean="authenticationManager"/></property>
      <property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
      <property name="runAsManager"><ref bean="runAsManager"/></property>
      <property name="afterInvocationManager"><ref bean="afterInvocationManager"/></property>
      <property name="objectDefinitionSource">
        <value>
          org.acegisecurity.context.BankManager.delete*=ROLE_SUPERVISOR,RUN_AS_SERVER
          org.acegisecurity.context.BankManager.getBalance=ROLE_TELLER,ROLE_SUPERVISOR,BANKSECURITY_CUSTOMER,RUN_AS_SERVER
        </value>
      </property>
    </bean>   这样可以利用切面控制方法的调用权限,看你的需要了
    详情参照
    http://www.acegisecurity.org/guide/springsecurity.html