正式綁定我有這個類在我的Spring Web模型 - 視圖 - 控制器(MVC)框架。我使用面向方面的編程(AOP),一種編程範式,旨在通過允許的橫切關注分離,以增加模塊性。 一切都很好與此類Spring MVC的:在切入點
@Aspect
public class MarketingAspect extends ServiceSupport {
@Pointcut("execution(* com.tdk.iot.services.client.LicenseService.*(..))")
public void handleServiceMethod() {
}
@Pointcut("execution(* com.tdk.iot.services.client.ApplicantService.*(..))")
public void handleApplicantServiceMethod() {
}
@Before("com.tdk.iot.services.aop.ApplicantAspect.handleServiceMethod()")
public void before(JoinPoint _jp) {
User user = getLDAPUser();
if(user != null &&((user.getUserRole() != UserRole.MARKETING)) {
throw new NoSufficientRoleException(user == null ? null : user.getUserRole(), UserRole.MARKETING);
}
}
@Before("com.tdk.iot.services.aop.ApplicantAspect.handleApplicantServiceMethod()")
public void checkRolebefore(JoinPoint _jp) {
User user = getLDAPUser();
if(user != null &&((user.getUserRole() != UserRole.MARKETING))) {
throw new NoSufficientRoleException(user == null ? null : user.getUserRole(), UserRole.MARKETING);
}
}
}
我已經改變了方法表示法getLDAPUser和現在接收的HttpServletRequest請求作爲參數,所以改性的方法
@Before("com.tdk.iot.services.aop.ApplicantAspect.handleApplicantServiceMethod()")
public void checkRolebefore(JoinPoint _jp, HttpServletRequest request) {
User user = getLDAPUser(request);
if(user != null &&((user.getUserRole() != UserRole.MARKETING))) {
throw new NoSufficientRoleException(user == null ? null : user.getUserRole(), UserRole.MARKETING);
}
}
和改性的此方法後我這個錯誤
java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
在我的XML:
<!-- Scan for aspects -->
<aop:aspectj-autoproxy />
<bean id="marketingAspect" class="com.tdk.iot.services.aop.MarketingAspect" />
並啓用Spring AOP的在你的配置xml文件?在 註釋 –
你能證明你的應用程序配置 – kuhajeyan
問題開始時,我修改方法如下:公共無效checkRolebefore(一個JoinPoint _jp,HttpServletRequest的請求){ –