我想向ControllerAdvice和ModelAttribute方法添加自定义参数。请参阅下面的代码。
@Target( { ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MyPage {
String param();
}
@Controller
public class MyController {
@RequestMapping...
@MyPage(param = "a")
public void myPage() {
....
}
}
@ControllerAdvice
public class MyAdviceController {
@ModelAttribute
public void addAttributes(Model model, MyPage myPage){
System.out.println(myPage.param());
}
}
如何让myPage参数工作。 我正在
class org.springframework.beans.BeanInstantiationException
Exception: Could not instantiate bean class [MyPage]: Specified class is an interface
我想用param()值“a”获取myPage对象