1

I want the code like this can be woking. How can I do?

@Target(value=ElementType.TYPE)
@Retention(value=RetentionPolicy.RUNTIME)
@Controller
@RequestMapping(value=RSI.DEFAULT_MAPPING + mapping())
public @interface RSI {
  public final static String DEFAULT_MAPPING = "/RSI";
  public String mapping() default "";
}


@RSI(mapping="/XXX")
public class XXXRSI {
Tan
  • 145
  • 1
  • 10
  • what do you exactlt want to do ? explain more? – Marcel Nov 30 '14 at 07:36
  • 1
    @AHC I want RSI annotation instead of Controller and RequestMapping. The path starts with /RSI – Tan Nov 30 '14 at 07:48
  • This article answers your question: [Why is not possible to extend annotations in Java?](http://stackoverflow.com/questions/1624084/why-is-not-possible-to-extend-annotations-in-java) I'm afraid it's not possible. – kemot90 Nov 30 '14 at 08:35

1 Answers1

1

Spring uses a number of classes (as beans registered in your MVC configuration) for registering and handling the handler methods you declare in a @Controller class. The two main classes you should look at are RequestMappingHandlerMapping and RequestMappingHandlerAdapter.

They have no built in way to do what you are suggesting. You'd have to extend those types (or write new ones with the appropriate interfaces) and register them instead of the ones above. This is not a trivial task.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724