NimChimpsky
NimChimpsky

Reputation: 47290

Which @controller annotation should I be using with Spring-mvc?

org.springframework.stereotype;

or

org.springframework.web.servlet.mvc;

I had been using the stereotype but just noticed I have another option ?

Upvotes: 0

Views: 205

Answers (1)

Aurand
Aurand

Reputation: 5537

org.springframework.stereotype.Controller

Is an annotation. It indicates that the annotated class is a controller as well as a candidate for auto-detection (like a @Component). This is the annotation you want to use.

org.springframework.web.servlet.mvc.Controller

Is an interface for implementing controllers. In most simple cases you probably don't want to be using this.

Upvotes: 3

Related Questions