不可能です。しかし、別の方法があります。URL から id パラメータを抽出する独自の Web 式を定義できます。次のようになります。
<security:intercept-url pattern="/user/{id}/edit" access="getIdUrlPathParameter() == principal.userId"/>
1. WebSecurityExpressionRoot を拡張する CustomWebSecurityExpressionRoot
を追加します
。 2. getIdUrlPathParameter() メソッドを追加します。HttpServletRequest オブジェクトにアクセスできます。
3. DefaultWebSecurityExpressionHandler
を拡張する CustomWebSecurityExpressionHandler を定義します。createSecurityExpressionRoot メソッドをオーバーライドし、ここで CustomWebSecurityExpressionRoot を使用します。
4. カスタム アクセス決定マネージャーを定義します (以下の xml)
。 5. access-decision-manager-ref 属性を介してhttp要素に挿入します。
<security:http access-decision-manager-ref="customAccessDecisionManagerBean" >
<security:intercept-url pattern="/user/{id}/edit" access="getIdUrlPathParameter() == principal.userId"/>
</security:http>
<bean id="customWebSecurityExpressionHandler" class="com.domain.security.CustomWebSecurityExpressionHandler"/>
<bean id="customAccessDecisionManagerBean" class="org.springframework.security.access.vote.AffirmativeBased">
<property name="decisionVoters">
<list>
<bean class="org.springframework.security.web.access.expression.WebExpressionVoter">
<property name="expressionHandler" ref="customWebSecurityExpressionHandler" />
</bean>
</list>
</property>
</bean>