@Controller
is used to mark classes as Spring MVC Controller.@RestController
is a convenience annotation that does nothing more than adding the@Controller
and@ResponseBody
annotations (see: Javadoc)
So the following two controller definitions should do the same
@Controller @ResponseBody public class MyController { } @RestController public class MyRestController { }
Related Posts:
- Spring @PropertySources value not overriding
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Spring boot – Request method ‘POST’ not supported. Tried everything
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- @Autowired – No qualifying bean of type found for dependency
- UnsatisfiedDependencyException: Error creating bean with name
- UnsatisfiedDependencyException: Error creating bean with name
- Why SpringMVC Request method ‘GET’ not supported?
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- Spring boot: Unable to start embedded Tomcat servlet container
- model.addAttribute() parameters
- Spring Boot – Unable to resolve Whitelabel Error Page
- Understanding Spring @Autowired usage
- com.atomikos.icatch.SysException: Error in init: Log already in use? tmlog in ./
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- “NoClassDefFoundError: Could not initialize class” error
- No String-argument constructor/factory method to deserialize from String value (”)
- “NoClassDefFoundError: Could not initialize class” error
- “NoClassDefFoundError: Could not initialize class” error
- What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?
- Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?
- com.sun.jdi.InvocationException occurred invoking method
- Only using @JsonIgnore during serialization, but not deserialization
- Spring Maven clean error – The requested profile “pom.xml” could not be activated because it does not exist
- intellij incorrectly saying no beans of type found for autowired repository
- Could not resolve placeholder in string value
- Is spring default scope singleton or not?
- MultipartException: Current request is not a multipart request
- How to upload a file and JSON data in Postman?
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- Configure active profile in SpringBoot via Maven
- Downloading a file from spring controllers
- java.lang.IllegalStateException: Failed to introspect Class
- when spring boot startup,throw out the “method names must be tokens” exception
- Could not reserve enough space for object heap
- What does “Could not find or load main class” mean?
- Exception in thread “main” java.util.NoSuchElementException
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- What’s the simplest way to print a Java array?
- javax vs java package
- What is a stack trace, and how can I use it to debug my application errors?
- How to fix “A JNI error has occurred, please check your installation.”
- Java Runtime Environment not found error when I open an application
- Java optional parameters
- How to update a value, given a key in a hashmap?
- How to schedule a periodic task in Java?
- typeof in Java 8
- Switch on Enum in Java
- error upon assigning Layout: BoxLayout can’t be shared
- Why do this() and super() have to be the first statement in a constructor?
- Else without if
- Keytool is not recognized as an internal or external command
- Java – Best way to print 2D array?
- “cannot find symbol: method” but the method is declared
- No enclosing instance of type is accessible.
- How to remove single character from a String
- What is the best math library to use with java?
- What is the difference between a null array and an empty array?
- Why is there no String.Empty in Java?
- How to initialize List
object in Java? - PrintWriter append method not appending
- How do I use the JAVA_OPTS environment variable?
- What is the difference between iterator and iterable and how to use them?
- Netbeans installation doesn’t find JDK
- Convert String to int array in java
- eclipse won’t start – no java virtual machine was found
- What causes “‘void’ type not allowed here” error
- Variable might not have been initialized error
- Java substring: ‘string index out of range’
- throw checked Exceptions from mocks with Mockito
- Java GUI: about getContentPane( ) method and content
- Hibernate Error: a different object with the same identifier value was already associated with the session
- The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template
- Initializing multiple variables to the same value in Java
- Java: Unresolved compilation problem
- FXML Load exception
- NullPointerExcetion Native Method Accessor… Hashing Words Issue
- Get keys from HashMap in Java
- Determine if a String is an Integer in Java [duplicate]
- How do I run Java .class files?
- Fill an array with random numbers [duplicate]
- Connection Java – MySQL : Public Key Retrieval is not allowed
- Whitespace Matching Regex – Java
- Keylistener not working for JPanel
- the getSource() and getActionCommand()
- Failed to install android-sdk: “java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema”
- Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven
- Regex pattern including all special characters
- Error: ‘)’ expected compiler error
- How does addNotify() and requestFocus() work in Java with JPanel?
- DTO and DAO concepts and MVC
- How to extract .war files in java? ZIP vs JAR
- How to print a table of information in Java
- set background color: Android
- Class Declarations for temperature program in Java
- Spring Boot – Cannot determine embedded database driver class for database type NONE
- Convert double to float in Java