- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company

Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
What is annotation processing in Java?
Quoting, Sun's Official Java Tutorial
Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested
What does it mean? And how to apply it?
- annotations

- docs.oracle.com/javase/tutorial/getStarted/problems/index.html – ROMANIA_engineer Jan 8, 2016 at 23:55
3 Answers 3
"Annotation Processing" is a hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then (by producing compiler errors, compiler warning, emitting source code, byte code ...).
API reference: javax.annotation.processing (Java Platform SE 6) .
From the very next line of the page that you refer to:
Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorldApp.java not javac HelloWorldApp.
That is, the string that you are referring to is a possible error that you might get when trying to compile the examples. The very next line in the document, tells you how to resolve the issue.
If you want to know more about annotations, what they are, and how to use them, then I would suggest to go through the Annotations tutorial .
- 1 Question: "What is annotation processing in Java?" – Daniel Earwicker Jan 27, 2010 at 10:55
- 1 @Earwicker: That is the title of the question, now read the text of the question: this page says blah, what does that mean? – Paul Wagland Jan 27, 2010 at 10:58
- 1 Yeah, I read it. It doesn't say the OP has hit any kind of compile error they can't fix. It says (again) they want to know what annotation processing is. – Daniel Earwicker Jan 27, 2010 at 11:02
- @Earwicker: I have updated my answer to answer both interpretations of the question. – Paul Wagland Jan 27, 2010 at 11:34
- Link to 'Annotations tutorial' is not valid – Marek J. Oct 15, 2018 at 7:55
This error is due to incorrect use of java compilation command i.e javac with file name w/o java extension (.java)
Use proper compilation command
javac HelloWorldApp.java
Command used foe execution
java HelloWorldApp
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged java annotations javac or ask your own question .
- The Overflow Blog
- Can Stack Overflow save the day?
- Let’s talk large language models (Ep. 546)
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- The Stack Exchange reputation system: What's working? What's not?
- Launching the CI/CD and R Collectives and community editing features for...
- Staging Ground Beta 1 Recap, and Reviewers needed for Beta 2
- Temporary policy: ChatGPT is banned
Hot Network Questions
- What does the letter in these ATC data blocks indicate?
- If one falls through the ice while ice fishing alone, how might one get out?
- How does the shot clock work in pool?
- Is an electron more stable than a proton/neutron?
- What is the last integer in this sequence?
- A ZFC example of a Menger space which is not Scheepers
- Cannot figure out how to turn off StrictHostKeyChecking
- Is there a name for the number of ones in a binary vector?
- Can someone be prosecuted for something that was legal when they did it?
- Joint owned property 50% each. Can 50% rent be charged?
- Would a freeze ray be effective against modern military vehicles?
- Stuck on a cryptanalytical research project
- How can I stay longer in my flight stop cities without much additional flight cost?
- Was Silicon Valley Bank's failure due to "Trump-era deregulation", and/or do Democrats share blame for it?
- A challenge between Sandman and Lucifer Morningstar
- Could a society develop without any time telling device?
- What's the point of issuing an arrest warrant for Putin given that the chances of him getting arrested are effectively zero?
- Understanding PID controller output value
- Why do the ISO/ETRTO numbers not match the English measure on my Tires?
- When writing log, do you indicate the base, even when 10?
- Adjoint of the Quantum Momentum Operator
- Practical usefulness of PCA
- How do unpopular policies arise in democracies?
- How much do several pieces of paper weigh?
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
Use annotation while sharing your screen in Teams
Annotation—powered by Microsoft Whiteboard—helps you collaborate on things like a design or presentation while sharing your screen in a Teams meeting.
Note: Annotation is available as part of the public preview program and might undergo further changes before being released publicly. To get access to this and other upcoming features, switch to Teams public preview .
Turn on and use annotation

The red outline around the shared screen will turn blue and all participants will see the Microsoft Whiteboard toolset at the top of the shared screen. Everyone in the meeting can begin annotating right away, and the red pen tool is selected by default.

To begin annotating, choose one of the tools in the Whiteboard toolset—like Sticky notes —and start typing or drawing on the screen.

Tip: You can take screenshots during the meeting if you’d like to reference the annotated content later. Note that the ability to start annotation and screenshot annotated content while you're presenting on a Mac is coming soon.
Annotation settings
Collaborative cursors show the names of every participant in the meeting by default. Anyone in the meeting can turn them off. To turn them off:

Turn off the toggle next to Collaborative cursors .

Turn off annotation
As the presenter, you can turn off annotation for all participants by selecting Stop annotation in the meeting controls at the upper-middle area of your screen.

Troubleshooting
If you don’t see the option to use annotation in a meeting:

2. Under Application , uncheck the box next to Disable GPU hardware acceleration (requires restarting Teams) .
Want to learn more? See Overview of meetings in Teams .
Related topics
Share content in a meeting
Whiteboard in a Teams meeting
As a meeting participant, you can annotate from mobile if the presenter is sharing from their desktop.

Need more help?
Expand your skills.
EXPLORE TRAINING >
Get new features first
JOIN MICROSOFT 365 INSIDERS >
Was this information helpful?
Thank you for your feedback.
What is Request Mapping Annotation in Spring Boot
In this tutorial we are going to learn about Request Mapping Annotation in Spring Boot with detailed explanation and examples.
Request Mapping Annotation in Spring Boot
@RequestMapping is a class level (also called type level) and method level annotation, it is used to process HTTP requests with specified URL patterns. It is used in and along with both @Controller and @RestController.
1. How @RequestMapping annotation it is used?
We can see in above code sample “/student” , “/dashboard” and “/result” passed with annotation are called request value/path present in the URL patterns.
The class StudentController will handle all the requests like example.com/students
And the member functions(methods) inside the class will handle the requests followed by the example.com/students/
dashboard() method will handle the request coming to example.com/students/dashboard.
result() method will handle the request coming to example.com/students/result
2. Optional Elements of @RequestMapping
All fields are public and abstract.
2.1 name, value and path
These elements are quit confusing, seems they are same.
- name - As in servlet mapping we assing name to the servlet class and url pattern and later it used in web.xml, in spring we can also assign name to the mapping.
value & path - according to official documentation both are alias of each other, both accept string array (see in table) ,both works similar, we can conversely use any of them. But the question arises, if they are doing same work then why they exist?
Remember! Spring Boot is built on the top of Spring framework, Boot is focused to reduce configuration overheads, other things work same as Spring.
2.2 headers, consumes and produces
headers - Headers are the meta data or extra message attached to HTTP requests. If we want to filter the request mappings on the basis of headers we need to specify that. It narrows down the mapping e.g.
it will accept all content types like “text/html”, “text/plain”, etc. Also we can see it contains expression “content-type=text” we can also negate that with != i.e “content-type!=text/” which means it will accept all “/something” having headers with content-type “application/json”, “application/xml” , “image/png”, “image/, etc except “text/“. Here * is wild card used for all.
3. Specialization of @RequestMapping
@RequestMapping specializations are created on basis of HTTP request methods, the other elements provided in the above table are used similarly as per the requirement.
- @GetMapping
- @PutMapping
- @PostMapping
- @DeleteMapping
- @PatchMapping
Spring Framework Guru
Using the spring @requestmapping annotation.

@RequestMapping is one of the most common annotation used in Spring Web applications. This annotation maps HTTP requests to handler methods of MVC and REST controllers.
In this post, you’ll see how versatile the @RequestMapping annotation is when used to map Spring MVC controller methods.
Request Mapping Basics
In Spring MVC applications, the RequestDispatcher (Front Controller Below) servlet is responsible for routing incoming HTTP requests to handler methods of controllers.
When configuring Spring MVC, you need to specify the mappings between the requests and handler methods.
The @RequestMapping annotation can be applied to class-level and/or method-level in a controller.
The class-level annotation maps a specific request path or pattern onto a controller. You can then apply additional method-level annotations to make mappings more specific to handler methods.
Here is an example of the @RequestMapping annotation applied to both class and methods.
With the preceding code, requests to /home will be handled by get() while request to /home/index will be handled by index() .
@RequestMapping with Multiple URIs
You can have multiple request mappings for a method. For that add one @RequestMapping annotation with a list of values.
As you can see in this code, @RequestMapping supports wildcards and ant-style paths. For the preceding code, all these URLs will be handled by indexMultipleMapping() .
- localhost:8080/home
- localhost:8080/home/
- localhost:8080/home/page
- localhost:8080/home/pageabc
- localhost:8080/home/view/
- localhost:8080/home/view/view
@RequestMapping with @RequestParam
The @RequestParam annotation is used with @RequestMapping to bind a web request parameter to the parameter of the handler method.
The @RequestParam annotation can be used with or without a value. The value specifies the request param that needs to be mapped to the handler method parameter, as shown in this code snippet.
In Line 6 of this code, the request param id will be mapped to the personId parameter personId of the getIdByValue() handler method.
An example URL is this: localhost:8090/home/id?id=5
The value element of @RequestParam can be omitted if the request param and handler method parameter names are same, as shown in Line 11.
An example URL is this: localhost:8090/home/personId?personId=5
The required element of @RequestParam defines whether the parameter value is required or not.
In this code snippet, as the required element is specified as false , the getName() handler method will be called for both of these URLs:
- /home/name?person=xyz
The default value of the @RequestParam is used to provide a default value when the request param is not provided or is empty.
In this code, if the person request param is empty in a request, the getName() handler method will receive the default value John as its parameter.
Using @RequestMapping with HTTP Method
The Spring MVC @RequestMapping annotation is capable of handling HTTP request methods, such as GET, PUT, POST, DELETE, and PATCH.
By default all requests are assumed to be of HTTP GET type.
In order to define a request mapping with a specific HTTP method, you need to declare the HTTP method in @RequestMapping using the method element as follows.
In the code snippet above, the method element of the @RequestMapping annotations indicates the HTTP method type of the HTTP request.
All the handler methods will handle requests coming to the same URL ( /home ), but will depend on the HTTP method being used.
For example, a POST request to /home will be handled by the post() method. While a DELETE request to /home will be handled by the delete() method.
You can see how Spring MVC will map the other methods using this same logic.
Using @RequestMapping with Producible and Consumable
The request mapping types can be narrowed down using the produces and consumes elements of the @RequestMapping annotation.
In order to produce the object in the requested media type, you use the produces element of @RequestMapping in combination with the @ResponseBody annotation.
You can also consume the object with the requested media type using the consumes element of @RequestMapping in combination with the @RequestBody annotation.
The code to use producible and consumable with @RequestMapping is this.
In this code, the getProduces() handler method produces a JSON response. The getConsumes() handler method consumes JSON as well as XML present in requests.
@RequestMapping with Headers
The @RequestMapping annotation provides a header element to narrow down the request mapping based on headers present in the request.
You can specify the header element as myHeader = myValue .
In the above code snippet, the headers attribute of the @RequestMapping annotation narrows down the mapping to the post() method. With this, the post() method will handle requests to /home/head whose content-type header specifies plain text as the value.
You can also indicate multiple header values like this:
Here it implies that both text/plain as well as text/html are accepted by the post() handler method.
@RequestMapping with Request Parameters
The params element of the @RequestMapping annotation further helps to narrow down request mapping. Using the params element, you can have multiple handler methods handling requests to the same URL, but with different parameters.
You can define params as myParams = myValue . You can also use the negation operator to specify that a particular parameter value is not supported in the request.
In this code snippet, both the getParams() and getParamsDifferent() methods will handle requests coming to the same URL ( /home/fetch ) but will execute depending on the params element.
For example, when the URL is /home/fetch?id=10 the getParams() handler method will be executed with the id value 10 .. For the URL, localhost:8080/home/fetch?personId=20 , the getParamsDifferent() handler method gets executed with the id value 20 .
Using @RequestMapping with Dynamic URIs
The @RequestMapping annotation is used in combination with the @PathVaraible annotation to handle dynamic URIs. In this use case, the URI values can act as the parameter of the handler methods in the controller. You can also use regular expressions to only accept the dynamic URI values that match the regular expression.
In this code, the method getDynamicUriValue() will execute for a request to localhost:8080/home/fetch/10 . Also, the id parameter of the getDynamicUriValue() handler method will be populated with the value 10 dynamically.
The method getDynamicUriValueRegex() will execute for a request to localhost:8080/home/fetch/category/shirt . However, an exception will be thrown for a request to /home/fetch/10/shirt as it does not match the regular expression.
@PathVariable works differently from @RequestParam . You use @RequestParam to obtain the values of the query parameters from the URI. On the other hand, you use @PathVariable to obtain the parameter values from the URI template.
The @RequestMapping Default Handler Method
In the controller class you can have default handler method that gets executed when there is a request for a default URI.
Here is an example of a default handler method.
In this code, A request to /home will be handled by the default() method as the annotation does not specify any value.
@RequestMapping Shortcuts
Spring 4.3 introduced method-level variants, also known as composed annotations of @RequestMapping . The composed annotations better express the semantics of the annotated methods. They act as wrapper to @RequestMapping and have become the standard ways of defining the endpoints.
For example, @GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET) . The method level variants are:
- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
The following code shows using the composed annotations.
In this code, each of the handler methods are annotated with the composed variants of @RequestMapping . Although, each variant can be interchangeably used with @RequestMapping with the method attribute, it’s considered a best practice to use the composed variant. Primarily because the composed annotations reduce the configuration metadata on the application side and the code is more readable.
@RequestMapping Conclusion
As you can see in this post, the @RequestMapping annotation is very versatile. You can use this annotation to configure Spring MVC to handle a variety of use cases. It can be used to configure traditional web page requests, and well as RESTFul web services in Spring MVC.
You May Also Like

JWT Token Authentication in Spring Boot Microservices

Hikari Configuration for MySQL in Spring Boot 2

Database Migration with Flyway

Getting Ready for Spring Framework 6

Using Filters in Spring Web Applications

Bootstrapping Data in Spring Boot

Eureka Service Registry

Scheduling in Spring Boot

Spring for Apache Kafka
Spring retry.

Spring Boot CLI

Actuator in Spring Boot

Internationalization with Spring Boot
One-to-one relationship in jpa.

The @RequestBody Annotation

Spring BeanFactory vs ApplicationContext

MySQL Stored Procedures with Spring Boot

Bean Validation in Spring Boot
Spring state machine.

Exception Handling in Spring Boot REST API

Spring Boot Pagination
Spring rest docs, using mapstruct with project lombok, argumentcaptor in mockito.

Reading External Configuration Properties in Spring
Api gateway with spring cloud.

Testing Spring Boot RESTful Services

Caching in Spring RESTful Service: Part 2 – Cache Eviction
Spring boot messaging with rabbitmq.

Caching in Spring Boot RESTful Service: Part 1

Implementing HTTP Basic Authentication in a Spring Boot REST API

Immutable Property Binding

Java Bean Properties Binding
External configuration data in spring.

Spring Data JPA @Query
Configuring mysql with circleci.

Fabric8 Docker Maven Plugin

Feign REST Client for Spring Application

Docker Hub for Spring Boot
Consul miniseries: spring boot application and consul integration part 3, run spring boot on docker, consul miniseries: spring boot application and consul integration part 2.

Consul Miniseries: Spring Boot Application and Consul Integration Part 1

Why You Should be Using Spring Boot Docker Layers

Spring Bean Scopes
Debug your code in intellij idea, stay at home, learn from home with 6 free online courses.

What is the best UI to Use with Spring Boot?

Best Practices for Dependency Injection with Spring

Should I Use Spring REST Docs or OpenAPI?
Spring boot with lombok: part 1.

Using Project Lombok with Gradle
Spring bean lifecycle, spring profiles, spring bean definition inheritance, autowiring in spring.

What is New in Spring Boot 2.2?

Using Ehcache 3 in Spring Boot
How to configure multiple data sources in a spring boot application.

Using RestTemplate with Apaches HttpClient

Using RestTemplate in Spring
Working with resources in spring, using spring aware interfaces, service locator pattern in spring, using graphql in a spring boot application, spring jdbctemplate crud operations, contracts for microservices with openapi and spring cloud contract, using swagger request validator to validate spring cloud contracts, spring 5 webclient, defining spring cloud contracts in open api.

Hibernate Show SQL

Spring Component Scan

Using CircleCI to Build Spring Boot Microservices
Spring framework annotations.

Using JdbcTemplate with Spring Boot and Thymeleaf

Spring Data MongoDB with Reactive MongoDB

Spring Boot with Embedded MongoDB

Spring Web Reactive

What are Reactive Streams in Java?

What’s new in Spring Framework 5?

Spring Boot RESTful API Documentation with Swagger 2

Mockito Mock vs Spy in Spring Boot Tests

Spring Boot Mongo DB Example Application

Configuring Spring Boot for MariaDB
Spring boot web application, part 6 – spring security with dao authentication provider.

Configuring Spring Boot for MongoDB

Spring Boot Web Application, Part 5 – Spring Security

Chuck Norris for Spring Boot Actuator
Testing spring mvc with spring boot 1.4: part 1, running spring boot in a docker container.

Jackson Dependency Issue in Spring Boot with Maven Build

Using YAML in Spring Boot to Configure Logback

Using Logback with Spring Boot

Using Log4J 2 with Spring Boot
Fixing nouniquebeandefinitionexception exceptions, samy is my hero and hacking the magic of spring boot.

2015 Year in Review

Configuring Spring Boot for PostgreSQL

Embedded JPA Entities Under Spring Boot and Hibernate Naming

Spring Boot Developer Tools
Spring beanfactoryaware interface.

Spring BeanNameAware Interface
Displaying list of objects in table using thymeleaf.

Using H2 and Oracle with Spring Boot

Configuring Spring Boot for Oracle

Spring Boot Web Application – Part 4 – Spring MVC

Configuring Spring Boot for MySQL

Spring Boot Example of Spring Integration and ActiveMQ
How do i become a java web developer.

Spring Boot Web Application – Part 3 – Spring Data JPA

Spring Boot Web Application – Part 2 – Using ThymeLeaf

Spring Boot Web Application – Part 1 – Spring Initializr

Using the H2 Database Console in Spring Boot with Spring Security
Running code on spring boot startup, integration testing with spring and junit.

Polyglot Programming in Spring

Using Spring Integration Futures
Using the spring framework for enterprise application development.

Testing Spring Integration Gateways

Introduction to Spring Expression Language (SpEL)

Hello World Using Spring Integration

Creating Spring Beans

Dependency Injection Example Using Spring

Hello World With Spring 4
Getting started with spring boot.

What’s all the fuss about Java Lambdas?
17 comments on “ using the spring @requestmapping annotation ”.
is this correct? @PathVariable works differently from @RequestParam. You use @PathVariable to obtain the values of the query parameters from the URI. On the other hand, you use @RequestParam to obtain the parameter values from the URI template.
I thought query parameters are those params after the ‘?’ in the URI, (?queryParam=value&queryParam2=value2). So you use @RequestParam. And the URI template is of the form /fetch/{id}, so you use @PathVariable to obtain the param values. Did I misunderstood the statement above?
Ximanta Sarma
That’s correct. @RequestParm is used for query parameters (that follows ‘?’) in URL, whereas @PathVariable for {placeholder} values that can keep dynamically changing in URL.
Yunus Emre Incu
hi thanx for your share. But i have a quest. What about the “dispatcher-servlet.xml” and “web.xml”… can you show me your xml files. Thanx.
These are no longer required.
Hi, Thanks for the useful blog. I have a requirement to create multiple instance of RestController with different dao, service instance properties. I’m working on to convert Jersey rest code to spring boot rest. I have sample code of Jersey implementation in stackoverflow. Please let me know if you could comment on this.
https://stackoverflow.com/questions/46876938/how-to-create-multiple-instances-of-restcontroller-in-spring-boot-application
Thanks in advance.
Nice summary. The only thing missing to make it a little better would be to show that handling of Objects both as input (in a POST for example) and as a response. Of course this would probably end up Jackson or some other OJM/OXM discussion.
Why would one add @ResponseBody annotation in a class annotated with @RestController? @RestController itself contains @ResponseBody…
Is it possible to specify a list of request parameters in a request mapping?
I have the following mapping: @PostMapping(value = “/test/url”, params = { “id={10, 20}” })
Yet when I submit the following request: http://localhost:8080/test/url?id=10&id=20
I get the following error: ServletRequestParameterException: Parameter conditions “id={10, 20}” not met for actual request parameters: id={10, 20}
Correction: The “method” value of @RequestMapping defaults to an empty array — it does NOT default to the GET method. So, one should always be explicit, to avoid possibly nondeterministic behavior if multiple annotations can apply to the same request URL.
See https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html#method–

Lana Rohdes
Java is the brandd and most powerful programmic language ever. It’s features like cross platform supported is one of the most powerful fetures, AEM is also a java based technology, So have a look. aem architecture
You are using @Produces=”application/json” and returning a simple string. i just want to know how spring can process this without returning a json convertible object.
Leave a Reply Cancel Reply
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
This site uses Akismet to reduce spam. Learn how your comment data is processed .

- Manage Email Subscriptions
- How to Post to DZone
- Article Submission Guidelines
- Manage My Drafts
Using the Spring @RequestMapping Annotation
As often as springs @requestmapping annotation is, few recognize its versatility. here, we see that on display when used to map spring mvc controller methods..
Join the DZone community and get the full member experience.
@RequestMapping is one of the most common annotation used in Spring Web applications. This annotation maps HTTP requests to handler methods of MVC and REST controllers.
In this post, you’ll see how versatile the @RequestMapping annotation is when used to map Spring MVC controller methods.
Request Mapping Basics
In Spring MVC applications, the RequestDispatcher (Front Controller Below) servlet is responsible for routing incoming HTTP requests to handler methods of controllers.
When configuring Spring MVC, you need to specify the mappings between the requests and handler methods.

The @RequestMapping annotation can be applied to class-level and/or method-level in a controller.
The class-level annotation maps a specific request path or pattern onto a controller. You can then apply additional method-level annotations to make mappings more specific to handler methods.
Here is an example of the @RequestMapping annotation applied to both class and methods.
With the preceding code, requests to /home will be handled by get() while request to /home/index will be handled by index().
@RequestMapping With Multiple URIs
You can have multiple request mappings for a method. For that add one @RequestMapping annotation with a list of values.
As you can see in this code, @RequestMapping supports wildcards and ant-style paths. For the preceding code, all these URLs will be handled by indexMultipleMapping().
- localhost:8080/home
- localhost:8080/home/
- localhost:8080/home/page
- localhost:8080/home/pageabc
- localhost:8080/home/view/
- localhost:8080/home/view/view
@RequestMapping With @RequestParam
The @RequestParam annotation is used with @RequestMapping to bind a web request parameter to the parameter of the handler method.
The @RequestParam annotation can be used with or without a value. The value specifies the request param that needs to be mapped to the handler method parameter, as shown in this code snippet.
In Line 6 of this code, the request param id will be mapped to the personId parameter personId of thegetIdByValue() handler method.
The value element of @RequestParam can be omitted if the request param and handler method parameter names are same, as shown in Line 11.
The required element of @RequestParam defines whether the parameter value is required or not.
In this code snippet, as the required element is specified as false, the getName() handler method will be called for both of these URLs:
- /home/name?person=xyz
The default value of the @RequestParam is used to provide a default value when the request param is not provided or is empty.
In this code, if the person request param is empty in a request, the getName() handler method will receive the default value John as its parameter.
Using @RequestMapping With HTTP Methods
The Spring MVC @RequestMapping annotation is capable of handling HTTP request methods, such as GET, PUT, POST, DELETE, and PATCH.
By default, all requests are assumed to be of HTTP GET type.
In order to define a request mapping with a specific HTTP method, you need to declare the HTTP method [email protected] using the method element as follows.
In the code snippet above, the method element of the @RequestMapping annotations indicates the HTTP method type of the HTTP request.
All the handler methods will handle requests coming to the same URL ( /home), but will depend on the HTTP method being used.
For example, a POST request to /home will be handled by the post() method. While a DELETE request to/home will be handled by the delete() method.
You can see how Spring MVC will map the other methods using this same logic.
Using @RequestMapping With Producible and Consumable
The request mapping types can be narrowed down using the produces and consumes elements of [email protected] annotation.
In order to produce the object in the requested media type, you use the produces element of @RequestMapping in combination with the @ResponseBody annotation.
You can also consume the object with the requested media type using the consumes element [email protected] in combination with the @RequestBody annotation.
The code to use producible and consumable with @RequestMapping is this.
In this code, the getProduces() handler method produces a JSON response. The getConsumes() handler method consumes JSON as well as XML present in requests.
@RequestMapping With Headers
The @RequestMapping annotation provides a header element to narrow down the request mapping based on headers present in the request.
You can specify the header element as myHeader = myValue.
In the above code snippet, the headers attribute of the @RequestMapping annotation narrows down the mapping to the post() method. With this, the post() method will handle requests to /home/head whose content-typeheader specifies plain text as the value.
You can also indicate multiple header values like this:
Here it implies that both text/plain as well as text/html are accepted by the post() handler method.
@RequestMapping With Request Parameters
The params element of the @RequestMapping annotation further helps to narrow down request mapping. Using the params element, you can have multiple handler methods handling requests to the same URL, but with different parameters.
You can define params as myParams = myValue. You can also use the negation operator to specify that a particular parameter value is not supported in the request.
In this code snippet, both the getParams() and getParamsDifferent() methods will handle requests coming to the same URL (/home/fetch) but will execute depending on the params element.
For example, when the URL is /home/fetch?id=10, the getParams() handler method will be executed with the id value 10.. For the URL, localhost:8080/home/fetch?personId=20, the getParamsDifferent() handler method gets executed with the id value 20.
Using @RequestMapping With Dynamic URIs
The @RequestMapping annotation is used in combination with the @PathVaraible annotation to handle dynamic URIs. In this use case, the URI values can act as the parameter of the handler methods in the controller. You can also use regular expressions to only accept the dynamic URI values that match the regular expression.
In this code, the method getDynamicUriValue() will execute for a request to localhost:8080/home/fetch/10. Also, the id parameter of the getDynamicUriValue() handler method will be populated with the value 10 dynamically.
The method getDynamicUriValueRegex() will execute for a request to localhost:8080/home/fetch/category/shirt. However, an exception will be thrown for a request to /home/fetch/10/shirt as it does not match the regular expression.
@PathVariable works differently from @RequestParam. You use @PathVariable to obtain the values of the query parameters from the URI. On the other hand, you use @RequestParam to obtain the parameter values from the URI template.
The @RequestMapping Default Handler Method
In the controller class, you can have default handler method that gets executed when there is a request for a default URI.
Here is an example of a default handler method.
In this code, a request to /home will be handled by the default() method as the annotation does not specify any value.
@RequestMapping Shortcuts
Spring 4.3 introduced method-level variants, also known as composed annotations of @RequestMapping. The composed annotations better express the semantics of the annotated methods. They act as wrapper [email protected] and have become the standard ways of defining the endpoints.
For example, @GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method =RequestMethod.GET). The method level variants are:
- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
The following code shows using the composed annotations.
In this code, each of the handler methods are annotated with the composed variants of @RequestMapping. Although each variant can be interchangeably used with @RequestMapping with the method attribute, it’s considered a best practice to use the composed variant —primarily because the composed annotations reduce the configuration metadata on the application side and the code is more readable.
@RequestMapping Conclusion
As you can see in this post, the @RequestMapping annotation is very versatile. You can use this annotation to configure Spring MVC to handle a variety of use cases. It can be used to configure traditional web page requests as well as RESTFul web services in Spring MVC.
Published at DZone with permission of John Thompson , DZone MVB . See the original article here.
Opinions expressed by DZone contributors are their own.
Popular on DZone
- JWT Authentication and Authorization: A Detailed Introduction
- Using GPT-3 in Our Applications
- Little's Law and Lots of Kubernetes
- 5 Software Developer Competencies: How To Recognize a Good Programmer
Partner Resources
- About DZone
- Send feedback
- Advertise with DZone
CONTRIBUTE ON DZONE
- Become a Contributor
- Visit the Writers' Zone
- Terms of Service
- Privacy Policy
- 600 Park Offices Drive
- Durham, NC 27709
- [email protected]
- +1 (919) 678-0300
Let's be friends:
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Enable pull request annotations in GitHub and Azure DevOps
- 4 minutes to read
- 2 contributors
Defender for DevOps exposes security findings as annotations in Pull Requests (PR). Security operators can enable PR annotations in Microsoft Defender for Cloud. Any exposed issues can then be remedied by developers. This process can prevent and fix potential security vulnerabilities and misconfigurations before they enter the production stage. Defender for DevOps annotates the vulnerabilities within the differences in the file rather than all the vulnerabilities detected across the entire file. Developers are able to see annotations in their source code management systems and Security operators can see any unresolved findings in Microsoft Defender for Cloud.
With Microsoft Defender for Cloud, you can configure PR annotations in Azure DevOps. You can get PR annotations in GitHub if you're a GitHub Advanced Security customer.
GitHub Advanced Security for Azure DevOps (GHAzDO) is providing a free trial of PR annotations during the Defender for DevOps preview.
Prerequisites
For GitHub :
- An Azure account. If you don't already have an Azure account, you can create your Azure free account today .
- Be a GitHub Advanced Security customer.
- Connect your GitHub repositories to Microsoft Defender for Cloud .
- Configure the Microsoft Security DevOps GitHub action .
For Azure DevOps :
- Connect your Azure DevOps repositories to Microsoft Defender for Cloud .
- Configure the Microsoft Security DevOps Azure DevOps extension .
- Setup secret scanning in Azure DevOps .
Enable pull request annotations in GitHub
By enabling pull request annotations in GitHub, your developers gain the ability to see their security issues when they create a PR directly to the main branch.
To enable pull request annotations in GitHub :
Navigate to GitHub and sign in.
Select a repository that you've onboarded to Defender for Cloud.
Navigate to Your repository's home page > .github/workflows .

Select msdevopssec.yml , which was created in the prerequisites .

Select edit .

Locate and update the trigger section to include:
You can also view a sample repository .
(Optional) You can select which branches you want to run it on by entering the branch(es) under the trigger section. If you want to include all branches remove the lines with the branch list.
Select Start commit .
Select Commit changes .
Any issues that are discovered by the scanner will be viewable in the Files changed section of your pull request.
Resolve security issues in GitHub
To resolve security issues in GitHub :
Navigate through the page and locate an affected file with an annotation.
Follow the remediation steps in the annotation. If you choose not to remediate the annotation, select Dismiss alert .
Select a reason to dismiss:
- Won't fix - The alert is noted but won't be fixed.
- False positive - The alert isn't valid.
- Used in tests - The alert isn't in the production code.
Enable pull request annotations in Azure DevOps
By enabling pull request annotations in Azure DevOps, your developers gain the ability to see their security issues when they create PRs directly to the main branch.
Enable Build Validation policy for the CI Build
Before you can enable pull request annotations, your main branch must have enabled Build Validation policy for the CI Build.
To enable Build Validation policy for the CI Build :
Sign in to your Azure DevOps project.
Navigate to Project settings > Repositories .

Select the repository to enable pull requests on.
Select Policies .
Navigate to Branch Policies > Main branch .

Locate the Build Validation section.
Ensure the build validation for your repository is toggled to On .

Select Save .

Once you've completed these steps, you can select the build pipeline you created previously and customize its settings to suit your needs.
Enable pull request annotations
To enable pull request annotations in Azure DevOps :
Sign in to the Azure portal .
Navigate to Defender for Cloud > DevOps Security .
Select all relevant repositories to enable the pull request annotations on.
Select Configure .

Toggle Pull request annotations to On .

(Optional) Select a category from the drop-down menu.
Only secret scan results are currently supported.
(Optional) Select a severity level from the drop-down menu.
Only high-level severity findings are currently supported.
All annotations on your main branch will be displayed from now on based on your configurations with the relevant line of code.
Resolve security issues in Azure DevOps
Once you've configured the scanner, you'll be able to view all issues that were detected.
To resolve security issues in Azure DevOps :
Sign in to the Azure DevOps .
Navigate to Pull requests .

On the Overview, or files page, locate an affected line with an annotation.
Follow the remediation steps in the annotation.
Select Active to change the status of the annotation and access the dropdown menu.
Select an action to take:
- Active - The default status for new annotations.
- Pending - The finding is being worked on.
- Resolved - The finding has been addressed.
- Won't fix - The finding is noted but won't be fixed.
- Closed - The discussion in this annotation is closed.
Defender for DevOps will reactivate an annotation if the security issue isn't fixed in a new iteration.
Learn more about Defender for DevOps .
Learn how to Discover misconfigurations in Infrastructure as Code .
Learn how to detect exposed secrets in code .
Now learn more about Defender for DevOps .
Submit and view feedback for
Additional resources
Annotation Interface RequestPart
- RequestParam
- RequestMappingHandlerAdapter
Optional Element Summary
Element details.
- Click to view our Accessibility Policy
- Skip to content
We suggest you try the following to help find what you’re looking for:
- Check the spelling of your keyword search.
- Use synonyms for the keyword you typed, for example, try "application" instead of "software."
- Start a new search.
- Create an Account
Technical Article
The java api for restful web services (jax-rs) -- rapidly build lightweight web services.
By Marc Hadley, July 2010
JAX-RS makes development of Java Web services built according to the Representational State Transfer (REST) architectural style both straightforward and natural.
INTRODUCTION
This article introduces you to the Java API for RESTful Web Services (JAX-RS), which resulted from Java Specification Request (JSR) 311 and is a component of the Java Enterprise Edition Platform (Java EE 6). The aim of JAX-RS is to make development of Java Web services built according to the Representational State Transfer (REST) architectural style both straightforward and natural for you, the developer. To this end, where possible, the API offers declarative annotations that allow you to:
- Identify components of the application
- Route requests to an appropriate method in a selected class
- Extract data from a request into the arguments of a method
- Provide metadata used in responses
JAX-RS also offers a number of utility classes and interfaces to aid with the more dynamic aspects of applications.
APPLICATIONS — THE UNIT OF DEPLOYMENT
When you use JAX-RS, the application is the unit of deployment. All of the files that make up an application are packaged together and deployed into some form of container that supplies HTTP services. A JAX-RS application consists of:
- Application subclass An optional Application subclass that defines the other classes that make up the application
- Root resource classes One or more root resource classes that define entry points into the URI space used by the application
- Providers Zero or more providers that supply extended functionality to the JAX-RS runtime.
Here is an example Application subclass:
The ApplicationPath annotation specifies the base URI path segment to which all root resource class URIs are relative. By default, all root resource classes and providers packaged with the Application subclass are included in the application. An Application subclass can also specify a subset of the packaged classes by overriding the getClasses method.
ROOT RESOURCE CLASSES
Root resource classes provide entry points into the URI space used by the application. Root resource classes are plain old Java objects (POJOs) that are annotated with @Path . Here is an example root resource class:
In the above, the root resource class is published at the relative URI widgets . If this class were part of the AcmeApplication shown earlier, then its URI path would be /acme/widgets .
The @GET annotation on the getWidgetList method indicates that the method is a resource method that you want to be called when an HTTP GET request is dispatched for that URI. Additional annotations are provided to support the other common HTTP methods. The set is extensible for other less common methods. The value returned from the method is converted into a response body by an entity provider. Returning a non-void Java type results in a 200 OK response, while a void method results in a 204 No Content response. As you will see shortly, the status returned in a response can be customized.
To expose a single widget as a resource, you can add a sub-resource method to the resource class as follows:
In the above, HTTP GET requests for /acme/widgets/{id} will be dispatched to the getWidget method. The {id} indicates that the path is a URI template that will match any URI with the prefix /acme/widgets/ and a single following path segment, e.g., /acme/widgets/foo .
EXTRACTING REQUEST DATA
In the previous example, the actual value of the template variable id is extracted from the request with the @Path-Param annotation and supplied as the value of the widgetId method argument. Additional annotations allow you to extract data from other parts of the request: URI query parameters with @Query-Param , URI matrix parameters with @MatrixParam , HTTP headers with @HeaderParam , and, finally, HTTP cookies with @CookieParam .
The type of method argument that carries one of the above annotations is any Java type with a String constructor or with a static method called valueOf or fromString that returns an instance of the type from a single String argument. For HTTP methods that support an entity body, such as POST, you can extract the data in the entity body into a Java method argument. Conversion from the serialized data in the request entity to a Java type is the responsibility of an entity provider, which we will explain shortly.
In addition to the declarative method of extracting request data described above, JAX-RS provides a set of interfaces that may be queried dynamically:
- Application Provides access to the Application subclass created by the JAX-RS runtime.
- UriInfo Provides access to the components of the request URI and convenience methods for creating new URIs based on the request URI.
- Request Provides methods for working with preconditions and dynamic content negotiation.
- HttpHeaders Provides methods for working with the content of HTTP request headers.
- SecurityContext Provides methods for determining the security context in which a request is executing.
- Providers Supports lookup of provider instances. This capability is useful in cases where one provider wants to re-use the functionality of another, e.g., an entity provider that supports some kind of composite entity might use other entity providers to read/write individual parts of the whole.
An instance of any of the above interfaces may be injected into a resource class field or method parameter using the @Context annotation, e.g.:
CUSTOMIZING THE RESPONSE
Responses often require a different status code than returned by default and certain types of responses may also require additional metadata in headers. In this case, the method can return an instance of the Response interface. A utility builder class is supplied that simplifies the construction of a custom response, e.g.:
or, more conveniently:
The JAX-RS runtime will convert relative URIs to absolute URIs when necessary and is also responsible for serialization of custom types used as header values.
BUILDING URIS
A RESTful application will use URIs extensively. The JAX-RS UriBuilder provides you with facilities for constructing URIs both from scratch and from existing URIs. It makes it easy for you to construct URIs based on the URI templates contained in @Path annotations . For example:
The createWidget method constructs widgetURI using:
- The request URI, e.g. http://.../acme/widgets.
- The relative URI template of the sub-resource ( {id} )extracted from the @Path annotation on the getWidget method
- The value of the URI template parameter contained in widgetId .
Prior to the call to the build method, the URI builder contains: http://.../acme/widgets/{id}
The arguments to the build method are substituted positionally for the URI template variables. Therefore, if widgetId contained the value ”foo” then the final value of widgetURI will be: http://.../acme/widgets/foo
EXCEPTION HANDLING
Exceptions thrown by a resource class method are caught by the JAX-RS runtime and converted to error responses. By default, exceptions are converted to a 500 Server Error response. JAX-RS offers two ways that you can customize the default error response:
- Methods can throw WebApplicationException which can contain a customized Response.
- The application can include a bundled exception mapping provider which will be called to create a customized Response when an exception is caught.
The two above methods can be mixed within an application. The second method is particularly well suited to cases where many methods can throw the same exception(s) since it naturally centralizes error response handling in one place.
DECLARATIVE CONTENT NEGOTIATION
As you have seen from prior examples, when dispatching requests to Java methods, the JAX-RS runtime does the following to route the request to the appropriate method:
- The request URI is compared to the URI templates supplied as values of @Path annotations.
- The request method is compared to method designator annotations ( @GET , @POST , etc.). JAX-RS also provides annotations that allow you to use different methods depending on the media types of the request and response.
- The media type of the request body ( Content-Type header) is compared to the value(s) of @Consumes annotations.
- The media type(s) that the client is requesting that the response use ( Accept header) is compared to the value(s) of @Produces annotations.
The order above denotes significance from most (request URI) to least (desired response media type). The dispatching algorithm proceeds in a number of phases. The first phase identifies the class whose @Path value most closely matches the request URI, therefore it is the most significant aspect. The value of the @Produces annotation is only considered in the final stage of matching -- therefore it is the least significant aspect. The exact algorithm used to match requests to the appropriate Java method is described in section 3.7 of the JAX-RS specification request.
Here is an example of declarative content negotiation:
In the above, a GET request for /acme/widgets with an Accept header value application/xml would be dispatched to the getXml method. Likewise, a GET request for the same URI with an Accept header of application/json would be dispatched to the getJson method.
PROVIDERS: FUNCTIONALITY FOR THE JAVA-RS RUNTIME
Providers are JAX-RS extensions that supply functionality to the JAX-RS runtime. The two main provider types are entity providers and exception mapping providers.
Entity Providers
Entity providers supply serialization and/or deserialization services between resource representations and their associated Java types. An entity provider that supports deserialization of a representation to a Java type implements the MessageBodyReader interface. An entity provider that supports serialization of a Java type to a representation implements the MessageBodyWriter interface.
Inclusion of an entity provider for a particular Java type in a JAX-RS application allows that type to be used as a resource method argument, as the return type for a resource method, or as the type of entity embedded in a returned Response . JAX-RS includes a number of built-in entity providers for common Java types including: String , InputStream , File and application-supplied JAXB classes. Entity providers may use the @Consumes and @Provides annotations to statically declare the media types that they support. They can also determine whether they support a particular media type and Java type at runtime to accommodate more complex providers.
Exception Mapping Providers
Exception mapping providers supply mapping services between Java exceptions and a JAX-RS Response. Exception mapping providers implement the ExceptionMapper interface and are called when a resource method throws a checked or runtime exception. The Response returned by an exception mapping provider is treated the same as a Response returned by a resource method: it may use any status code and may contain headers. Any contained entity will be serialized using an appropriate entity provider.
JAX-RS is an annotation-driven Java API that aims to make development of Web services built according to the Representational State Transfer (REST) architectural style in Java both straightforward and intuitive for you, the developer. It should enable you to more rapidly build lightweight web services that conform to the REST software style. Good luck with JAX-RS!
- Country/Region
- Data Structure & Algorithm Classes (Live)
- System Design (Live)
- DevOps(Live)
- Explore More Live Courses
- Interview Preparation Course
- Data Science (Live)
GATE CS & IT 2024
- Data Structure & Algorithm-Self Paced(C++/JAVA)
- Data Structures & Algorithms in Python
- Explore More Self-Paced Courses
- C++ Programming - Beginner to Advanced
- Java Programming - Beginner to Advanced
- C Programming - Beginner to Advanced
- Full Stack Development with React & Node JS(Live)
- Java Backend Development(Live)
- Android App Development with Kotlin(Live)
- Python Backend Development with Django(Live)
- Complete Data Science Program(Live)
- Mastering Data Analytics
- DevOps Engineering - Planning to Production
- CBSE Class 12 Computer Science
- School Guide
- All Courses
- Linked List
- Binary Tree
- Binary Search Tree
- Advanced Data Structure
- All Data Structures
- Asymptotic Analysis
- Worst, Average and Best Cases
- Asymptotic Notations
- Little o and little omega notations
- Lower and Upper Bound Theory
- Analysis of Loops
- Solving Recurrences
- Amortized Analysis
- What does 'Space Complexity' mean ?
- Pseudo-polynomial Algorithms
- Polynomial Time Approximation Scheme
- A Time Complexity Question
- Searching Algorithms
- Sorting Algorithms
- Graph Algorithms
- Pattern Searching
- Geometric Algorithms
- Mathematical
- Bitwise Algorithms
- Randomized Algorithms
- Greedy Algorithms
- Dynamic Programming
- Divide and Conquer
- Backtracking
- Branch and Bound
- All Algorithms
- Company Preparation
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Design Patterns
- System Design Tutorial
- Multiple Choice Quizzes
- Go Language
- Tailwind CSS
- Foundation CSS
- Materialize CSS
- Semantic UI
- Angular PrimeNG
- Angular ngx Bootstrap
- jQuery Mobile
- jQuery EasyUI
- React Bootstrap
- React Rebass
- React Desktop
- React Suite
- ReactJS Evergreen
- ReactJS Reactstrap
- BlueprintJS
- TensorFlow.js
- English Grammar
- School Programming
- Number System
- Trigonometry
- Probability
- Mensuration
- Class 8 Syllabus
- Class 9 Syllabus
- Class 10 Syllabus
- Class 11 Syllabus
- Class 12 Syllabus
- Class 8 Notes
- Class 9 Notes
- Class 10 Notes
- Class 11 Notes
- Class 12 Notes
- Class 8 Formulas
- Class 9 Formulas
- Class 10 Formulas
- Class 11 Formulas
- Class 8 Maths Solution
- Class 9 Maths Solution
- Class 10 Maths Solution
- Class 11 Maths Solution
- Class 12 Maths Solution
- Class 7 SS Syllabus
- Class 8 SS Syllabus
- Class 9 SS Syllabus
- Class 10 SS Syllabus
- Class 7 Notes
- History Class 7
- History Class 8
- History Class 9
- Geo. Class 7
- Geo. Class 8
- Geo. Class 9
- Civics Class 7
- Civics Class 8
- Business Studies (Class 11th)
- Microeconomics (Class 11th)
- Statistics for Economics (Class 11th)
- Business Studies (Class 12th)
- Accountancy (Class 12th)
- Macroeconomics (Class 12th)
- Machine Learning
- Data Science
- Mathematics
- Operating System
- Computer Networks
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- GATE 2024 Live Course
- GATE Computer Science Notes
- Last Minute Notes
- GATE CS Solved Papers
- GATE CS Original Papers and Official Keys
- GATE CS 2023 Syllabus
- Important Topics for GATE CS
- GATE 2023 Important Dates
- Software Design Patterns
- HTML Cheat Sheet
- CSS Cheat Sheet
- Bootstrap Cheat Sheet
- JS Cheat Sheet
- jQuery Cheat Sheet
- Angular Cheat Sheet
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- Wipro Coding Sheet
- Infosys Coding Sheet
- TCS Coding Sheet
- Cognizant Coding Sheet
- HCL Coding Sheet
- FAANG Coding Sheet
- Love Babbar Sheet
- Mass Recruiter Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Array Sheet
- String Sheet
- Graph Sheet
- ISRO CS Original Papers and Official Keys
- ISRO CS Solved Papers
- ISRO CS Syllabus for Scientist/Engineer Exam
- UGC NET CS Notes Paper II
- UGC NET CS Notes Paper III
- UGC NET CS Solved Papers
- Campus Ambassador Program
- School Ambassador Program
- Geek of the Month
- Campus Geek of the Month
- Placement Course
- Testimonials
- Student Chapter
- Geek on the Top
- Geography Notes
- History Notes
- Science & Tech. Notes
- Ethics Notes
- Polity Notes
- Economics Notes
- UPSC Previous Year Papers
- SSC CGL Syllabus
- General Studies
- Subjectwise Practice Papers
- Previous Year Papers
- SBI Clerk Syllabus
- General Awareness
- Quantitative Aptitude
- Reasoning Ability
- SBI Clerk Practice Papers
- SBI PO Syllabus
- SBI PO Practice Papers
- IBPS PO 2022 Syllabus
- English Notes
- Reasoning Notes
- Mock Question Papers
- IBPS Clerk Syllabus
- Apply for a Job
- Apply through Jobathon
- Hire through Jobathon
- All DSA Problems
- Problem of the Day
- GFG SDE Sheet
- Top 50 Array Problems
- Top 50 String Problems
- Top 50 Tree Problems
- Top 50 Graph Problems
- Top 50 DP Problems
- Solving For India-Hackthon
- GFG Weekly Coding Contest
- Job-A-Thon: Hiring Challenge
- BiWizard School Contest
- All Contests and Events
- Saved Videos
- What's New ?
- Data Structures
- Interview Preparation
- Topic-wise Practice
- Latest Blogs
- Write & Earn
- Web Development
Related Articles
- Write Articles
- Pick Topics to write
- Guidelines to Write
- Get Technical Writing Internship
- Write an Interview Experience
- Bash Scripting - If Statement
- How to Set Upstream Branch on Git?
- Java Developer Learning Path – A Complete Roadmap
- Spring Boot - Sending Email via SMTP
- How to render an array of objects in ReactJS ?
- Spring @Bean Annotation with Example
- Spring Boot - Exception Handling
- Comparable Interface in Java with Examples
- Best Way to Master Spring Boot – A Complete Roadmap
- MVC Framework Introduction
- How to Set Up an Emulator For VSCode?
- How to Embed PDF file using HTML ?
- How to do crud operations in ReactJS ?
- How to Install Python Packages for AWS Lambda Layers?
- How to Create a Pie Chart in Seaborn?
- Spring - REST JSON Response
- Software Testing - Boundary Value Analysis
- How to upload image and Preview it using ReactJS ?
- OSI Security Architecture
- How to fetch data from the database in PHP ?
- Spring Boot Kafka Consumer Example
- How To Convert Numpy Array To Tensor?
- Spring @Configuration Annotation with Example
- Spring Boot - Architecture
- PostgreSQL - Connect and Access a Database
- How to connect ReactJS as a front-end with PHP as a back-end ?
- How to Sort Golang Map By Keys or Values?
- Spring @Value Annotation with Example
- Python Plotly: How to set up a color palette?
- How to Conduct a Two Sample T-Test in Python
Spring – MVC RequestParam Annotation
- Difficulty Level : Medium
- Last Updated : 09 Mar, 2022
@RequestParam annotation enables spring to extract input data that may be passed as a query, form data, or any arbitrary custom data. Here, we will see how we can use @RequestParam when building RESTful APIs for a web-based application.
Context of the Application: Let us suppose we are implementing a sample feature for the ‘Geeksforgeeks’ web application, where users will be able to post and retrieve article topics available to write articles on them. Here we will be using hashmaps as our database for simplicity. We use static block to load default entry into our hashmap/DB.
Illustration:
Simple mapping Using @RequestParam
Let’s say we have an endpoint /api/v1/article which takes a query parameter articleId where users will be able to get the article topic given the article id. If the given articleId is not present we return “Article not accepted” as a response with 404 Bad Request as status.
Note: Static blocks executes automatically when the class is loaded in memory. Annotation @GetMapping is used for mapping HTTP GET requests for specific handler methods. ResponseEntity represents an HTTP response which includes headers, body and status. Postman is used for testing the APIs.
When we tried to get the article already present in our database, we get the required response body with ‘200 OK’ as status code.
When we tried to get the article not present in our database, we get the “Article not present” response body with 400 BAD REQUEST as status code.
Specifying the Request Parameter Name Using @RequestParam
Let’s say we have an endpoint /api/v2/article for posting article topics which takes a query parameter articleName as name .
When we tried to get the article doesn’t exist in our database, we save the request and return a response with 200 OK as status code.
When we tried to get the article already present in our database, we get the “Article already exists” response body with 400 BAD REQUEST as status code.
Using @RequestParam with Default Value
Let’s say we have an endpoint /api/v3/article for getting article topics which takes a query parameter articleId. Here we have used defaultValue attribute which takes the default value if no value is provided.
If no value is provided for the query parameter, then return the default value.
If the value provided doesn’t exist in the database, then also return the default value.
Using @RequestParam For Mapping Multiple Value Query Parameter
Let’s say we have an endpoint /api/v4/article for posting article topics which takes a list as a query parameter.
Implementation:
Note : @RestController is a convenience annotation used for creating Restful controllers.
Dependencies: Gradle
Please Login to comment...
- Geeks-Premier-League-2022
- Java-Spring
- Java-Spring-MVC
- Geeks Premier League

JAVA Backend Development - Live

Master Java Programming - Complete Beginner to Advanced

Complete Machine Learning & Data Science Program

DSA Live for Working Professionals - Live

Complete Interview Preparation - Self Paced

Competitive Programming - Live

Python Programming Foundation -Self Paced

Complete Test Series for Service-Based Companies

JavaScript Foundation - Self Paced

Data Structures and Algorithms - Self Paced
Improve your coding skills with practice, start your coding journey now.
// Tutorial //
Spring restcontroller.

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
Spring RestController annotation is a convenience annotation that is itself annotated with @Controller and @ResponseBody . This annotation is applied to a class to mark it as a request handler. Spring RestController annotation is used to create RESTful web services using Spring MVC. Spring RestController takes care of mapping request data to the defined request handler method. Once response body is generated from the handler method, it converts it to JSON or XML response.
Spring RestController Example

Spring RestController Maven Dependencies
Let’s have a look at the dependencies required to create our Spring RestController example project.
We need Spring MVC, Jackson and JAXB libraries to support both XML and JSON requests and responses from our REST web service. Our web.xml file is used to configure Spring MVC DispatcherServlet as the front controller. Let’s look at the Spring Context file now.
Most important part is the jsonMessageConverter and xmlMessageConverter beans defined and set in the RequestMappingHandlerAdapter messageConverters property. That’s all is needed to tell spring that we want our application to support both JSON and XML and these are the beans to be used for transformation.
Spring RestController Class
Here is our Spring RestController class implementation.
Notice that we have only defined our REST APIs here, all the business logic is part of Repository class. If our method is returning a list or array, then spring will only support JSON response because XML root element can’t be anonymous but JSON can. If you want to support returning list as XML, then you will have to create a wrapper class to hold this list and return it. We are expecting Employee object as the request in some of the methods, Spring will take care of parsing the request body and converting it to the Employee object for these methods. Similarly, we are returning Employee object as the Response Body, again Spring will take care of converting it to JSON/XML response.
Accept and Content-Type Request Headers
We have configured our REST application to work with both XML and JSON. So how it will know that whether the request is XML or JSON. And if the response should be sent in JSON or XML format. This is where Accept and Content-Type Request Headers are used. Content-Type : Defined the type of content in request body, if its value is “application/xml” then Spring will treat request body as XML document. If its value is “application/json” then the request body is treated as JSON. Accept : Defined the type of content client is expecting as response. If its value is “application/xml” then XML response will be sent. If its value is “application/json” then JSON response will be sent.
Spring RestController Test
Our application is ready to be tested, I have deployed it on Tomcat-9 and testing with Postman. Below are the testing results with the explanation.
Spring RestController GET JSON Response

Spring RestController GET XML Response

Spring RestController GET List

Spring RestController POST

Spring RestController DELETE

Spring RestController helps us in focusing on business logic by taking care of all the boiler-plate stuffs for creating REST web services APIs.
You can download the complete project from our GitHub Repository .
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Learn more about us
Still looking for an answer?
how to create project which type of project is this

Popular Topics
- Linux Basics
- All tutorials
- Free Managed Hosting
Try DigitalOcean for free
Join the tech talk.
Please complete your information!

Annotating documents
What is an annotation.
Annotations are comments, notes, explanations, or other types of external remarks that can be attached to a Web document or to a selected part of a document. As they are external, it is possible to annotate any Web document independently, without needing to edit the document itself. From a technical point of view, annotations are usually seen as metadata, as they give additional information about an existing piece of data. Amaya uses a special RDF annotation schema for describing annotations.

An annotation has many properties including:
- Physical location: is the annotation stored in the local file system or in an annotation server
- Scope: is the annotation associated to a whole document or just to a fragment.
- Annotation type: 'Annotation', 'Comment', 'Query', ...
Local and remote annotations
Amaya can store annotation data in a local file system ( local annotations ) or it can store annotations remotely, on annotations servers accessed through the Web ( remote annotations ).
You do not need a server to create local annotations. Local annotations are stored under your AmayaHome directory, in a special directory called annotations , and they can be seen only by their owner (according to the system access right setup).
This directory contains three kinds of files:
- annot.index: Associates URLs with the files containing the metadata of the annotations.
- index + random suffix: Stores the metadata of the annotations related to a given URL. The metadata is specified in RDF.
- annot + random suffix.html: Contains the body of an annotation, stored as XHTML.
At any time, you can convert a local annotation to a shared one by choosing Post to server from the Tools/Annotations submenu. Once this is completed, the local annotation is deleted because it has been moved to an annotation server.
Remote annotations
You can store remote annotations in annotation servers so that the annotations can be downloaded by anyone having the correct access rights, such as is the case of other HTML documents.
Remote annotations are referred to as shared or public annotations, because they can be seen by other people. If you wish to install your own annotation server, please refer to Annotation-Server-HOWTO .
Creating an annotation
Before creating an annotation, it is recommended to set some parameters in the Preferences (see section Configuring annotations ).
Amaya supports two kinds of annotations: annotations that apply to a whole document and annotations that apply to a specific position or a selection in a document.
- To annotate an entire document, choose Annotate document from the Tools/Annotations menu.
- To annotate a position, put the insertion point at that position in the document and choose Annotate selection from the Tools/Annotations menu.
- To annotate a selection, make a selection in the document and choose Annotate selection from the Tools/Annotations menu.
After these operations, an annotation document is displayed, with some inital metadata and an empty body.
The metadata consists of the title of the annotation , the author's name , the title of the annotated document, the annotation type , the creation date , and the last modification date .
Some of the metadata fields have special properties:
- The Source document field is a link that points back to the annotated text. If the user double-clicks it, as when following any other link with Amaya, the annotated document will be displayed with the annotated text highlighted.
- The Annotation types field lets you classify the annotation and change its type. Double-click on the text Annotation type to see the list of types available.
- The Last modified field is updated automatically each time that an annotation is saved.
Below the header area is the annotation body area. It shows the current content and can be edited like any other HTML document.
Some commands that can be applied to a document in the Amaya document window also can be applied to an annotation document in the Annotation window. For example, the body of an annotation can be printed by choosing Print from the File menu, or reloaded by choosing Reload document from the File menu.
Saving an annotation
Saving an annotation is the same as saving any other document with Amaya: choose Save from the File menu (or use its equivalent shortcut or button) or press the Save button.
Local annotations are saved to the annotations directory and remote annotations are saved to the annotation post server, if the user has write access.
To convert a local annotation into a shared one, choose Post to server from the Tools/Annotations menu to save the annotation to the Post server as defined in the Configuration for Annotations dialog . If this operation is successful, the local annotation will be removed and future Save operations will go directly to that annotation server.
Deleting an annotation
The Delete command on the Tools/Annotations submenu enables you to delete the current annotation. You can invoke this command from an annotation window.
You can also delete an annotation from the annotated document. Select the icon of the annotation and call the same command from the Tools menu in the annotated document window.
Loading and presenting annotations
The Tools/Annotations/Load command tells Amaya to load the annotations that are associated with the URL of the current document. Amaya will query the annotation servers, using the settings from Preferences/Annotations , and ask for any relevant annotation.
Annotations may also be loaded automatically whenever a new page is viewed by selecting the Autoload remote annotations check box in Preferences/Annotations .
Querying an annotation server returns all the annotations that are associated with a document.
Annotations in the Links window
The link view of the annotated document shows all the annotations.
As with the document window, annotations are identified by a pencil icon. A single-click on the icon selects the annotated text in the document window and a double-click opens the annotation.
Replying to annotations / discussion thread
Annotations can be seen as comments to web pages. The Tools/Annotations/Reply to annotation command enhances the collaborative workspace by allowing users to reply to annotations or to other replies.
The Reply to annotation command of the Tools/Annotations submenu lets you create a reply to an existing annotation or to a reply. You can invoke this command from an open annotation or a reply window.
As a result a new annotation document opens. The fields in a reply annotation can be edited just like in any other annotation as explained under Creating an annotation .
When the reply is ready, you can post it to a server with the Tools/Annotations/Post to server command or you can save it locally using the File/Save command. To delete a reply, you can use the Tools/Annotations/Delete command.
Replies can also be annotated like any other document, as explained in Creating an annotation .
All replies related to an annotation are shown at the bottom of this annotation, in a thread section. Each item in the thread gives the date of the reply, the author, and the title of the reply.
The content of any of these replies can be retrieved by double clicking the replies in the thread. The selected reply is highlighted and presented in a reply tab. When another selection is made the same reply tab is used.
Known issues: incomplete thread
There is no way to control which replies should be posted. In an ideal world, it should not be possible to save a reply to a reply if the previous reply was not saved in the same server. Likewise, if you delete a reply, you should delete all replies to this annotation. Not doing that leads to having fragments of threads that cannot be correctly attached in the thread.
For example, let R1 be the reply to annotation A1 and R2 a reply to R1. If you post R1, and let R2 be stored locally, then when you browse A1 and only download its local annotations, you will only see R2.
At this point, Amaya does not know that R1 exists, so it assumes that R2 has lost its parent. We identify these "orphan" threads by putting a question mark symbol ? in front of them. If later one, Amaya finds new thread items, for example, if you download R1, Amaya will then sort the thread view, inserting the threads as appropriately. In our example, R2 will become a child of R1, as expected.
Configuring annotation icons
User-definable icons by annotation type (aka "dynamic icons").
The icon used to mark the location of an annotation within an annotated document may be changed by the user. The icon that denotes an annotation is chosen as a property of the annotation type. By including an RDF property of each annotation type you wish to use, you select the icon associated with annotations of that type.
The sample configuration associates the following icons:
The property name for adding annotation icons is http://www.w3.org/2001/10/typeIcon#usesIcon . For instance, to specify an icon named file:///home/question-icon.jpg for annotations that have type http://www.w3.org/2000/10/annotationType#Question you would enter the following RDF/XML into a file that Amaya reads at startup is:
The simplest way to get such RDF loaded into Amaya at startup is to include the file in the config/annot.schemas file in the Amaya program directory. In order to preserve this file so that it will not be overwritten when you install a new version of Amaya, you should copy the config/annot.schemas file into your personal AmayaHome directory.
You may list as many RDF files as you want in annot.schemas . See the comments in the file included in the Amaya kit for more details.
A sample file named typeIcon.rdf declares unique icons for each annotation type declared in the http://www.w3.org/2000/10/annotationType# namespace. To experiment with user-defined icons, it may be easiest to copy this typeIcon.rdf into another directory and modify it. Copy annot.schemas to your AmayaHome directory and change the line near the end to point to your revised icon definition file.
Amaya supports JPEG, PNG, and GIF bitmap graphics formats for icon images. The icon URI may only be a file: URI; that is, the icon must appear in a local or mounted directory to Amaya. Two special forms of non-file: URIs are supported. If the file path name starts with $THOTDIR or $APP_HOME then the corresponding Amaya installation directory or personal Amaya home directory is substituted into the pathname.
Known issues with annotations and modified documents
When you use annotations with live documents (documents whose contents can be modified), you may encounter two kinds of problems: orphan annotations and misleading annotations . To explain these problems, we must first describe how Amaya attaches annotations to documents.
Amaya uses XPointer to indicate where an annotation should be attached to a document. XPointers are based in the structure of the document. To build an XPointer for a selection, for example, Amaya starts from the first point of the selection and walk backwards through the document's structure, until it finds the root of the document. If an element has an id attribute, Amaya stops building the XPointer and considers the element with the id attribute value to be the beginning of that XPointer.
For example, if you look at the HTML source for this document, you'll notice that this section is enclosed within a div element that has an id attribute with the value "Issues" Here's an extract of the source code:
This XPointer points to the second paragraph: xpointer(id("Issues")/p[2])
The above XPointer points to the second p element, from the element parent having an id attribute with value "Issues".
Note that the use of the id attribute enables the document author to move the entire reference by the XPointer to another location within the document, without needing to update the XPointer. The XPointer does not depend on the elements that precede it.
Orphan annotations
An annotation becomes an "orphan" when it can no longer be attached to a document, that is, when the XPointer does not resolve to any element in the structure. This happens when a document's structure is modified. Amaya displays a warning if it detects any orphan annotations while downloading a set of annotations from an annotation server. All orphan annotations are visible from the Links view and are associated with an icon that shows a question mark superimposed on the annotation pencil .
Misleading annotations
An annotation becomes "misleading" when it points to a wrong piece of information. This problem is common when you annotate a portion of text that may change. In the first release, Amaya does not warn the user if an annotation is misleading. A future release may notify users of the potential for an annotation to be misleading.
What can you do to avoid this?
As the author of a document, try to use the ID attribute in strategic places, for example, inside <DIV> and p elements. For example:
An XPointer that points to this paragraph is: xpointer(id("Amaya"))
Thus, the Xpointer will point to the same paragraph, regardless of its position in the document's structure.
Amaya enables you to automatically associate with or remove an ID attribute to/from a set of elements by choosing Add/Remove IDs from the Links menu.

Java Guides
Search this blog.
Check out my 10+ Udemy bestseller courses and discount coupons: Udemy Courses - Ramesh Fadatare
Spring @RequestBody and @ResponseBody Annotations
@requestbody annotation.
@ResponseBody Annotation
Behind the scenes.
@RestController Annotation
To know about @Controller and @RestController annotation in-detail at The Spring @Controller and @RestController Annotations with Examples
Related Spring and Spring Boot Annotations
- Spring Boot @Bean Annotation Example
- Spring @Qualifier Annotation Example
- Spring @Autowired Annotation with Example
- Spring @Bean Annotation with Example
- Spring @Configuration Annotation with Example
- Spring @PropertySource Annotation with Example
- Spring @Import Annotation with Example
- Spring @ImportResource Annotation Example
- Spring - @Lazy Annotation Example
- Spring - @Primary Annotation Example
- Spring @PostConstruct and @PreDestroy Example
- Spring @Repository Annotation
- Spring @Service Annotation
- The Spring @Controller and @RestController Annotations
- Spring Boot @Component, @Controller, @Repository and @Service
- Spring @Scope annotation with Prototype Scope Example
- Spring @Scope annotation with Singleton Scope Example
- Spring Boot @PathVariable
- Spring Boot @ResponseBody
- Spring @RequestBody - Binding Method Parameters to Request Body
- Spring Boot @ResponseStatus Annotation
- Spring Boot - Creating Asynchronous Methods using @Async Annotation
- @SpringBootTest Spring Boot Example
- @SpringBootTest vs @WebMvcTest
- @DataJpaTest Spring Boot Example
- Spring @GetMapping, @PostMapping, @PutMapping, @DeleteMapping and @PatchMapping
- Spring Boot @EnableAutoConfiguration Annotation with Example
- Spring Boot @SpringBootApplication Annotation with Example
Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours
Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course
Post a Comment
Copyright © 2018 - 2025 Java Guides All rights reversed | Privacy Policy | Contact | About Me | YouTube | GitHub

- Research Guides
- CECH Library
How to Write an Annotated Bibliography
Writing annotations.
- Introduction
- New RefWorks
- Formatting Citations
- Sample Annotated Bibliographies
An annotation is a brief note following each citation listed on an annotated bibliography. The goal is to briefly summarize the source and/or explain why it is important for a topic. They are typically a single concise paragraph, but might be longer if you are summarizing and evaluating.
Annotations can be written in a variety of different ways and it’s important to consider the style you are going to use. Are you simply summarizing the sources, or evaluating them? How does the source influence your understanding of the topic? You can follow any style you want if you are writing for your own personal research process, but consult with your professor if this is an assignment for a class.
Annotation Styles
- Combined Informative/Evaluative Style - This style is recommended by the library as it combines all the styles to provide a more complete view of a source. The annotation should explain the value of the source for the overall research topic by providing a summary combined with an analysis of the source.
Aluedse, O. (2006). Bullying in schools: A form of child abuse in schools. Educational Research Quarterly , 30 (1), 37.
The author classifies bullying in schools as a “form of child abuse,” and goes well beyond the notion that schoolyard bullying is “just child’s play.” The article provides an in-depth definition of bullying, and explores the likelihood that school-aged bullies may also experience difficult lives as adults. The author discusses the modern prevalence of bullying in school systems, the effects of bullying, intervention strategies, and provides an extensive list of resources and references.
Statistics included provide an alarming realization that bullying is prevalent not only in the United States, but also worldwide. According to the author, “American schools harbor approximately 2.1 million bullies and 2.7 million victims.” The author references the National Association of School Psychologists and quotes, “Thus, one in seven children is a bully or a target of bullying.” A major point of emphasis centers around what has always been considered a “normal part of growing up” versus the levels of actual abuse reached in today’s society.
The author concludes with a section that addresses intervention strategies for school administrators, teachers, counselors, and school staff. The concept of school staff helping build students’ “social competence” is showcased as a prevalent means of preventing and reducing this growing social menace. Overall, the article is worthwhile for anyone interested in the subject matter, and provides a wealth of resources for researching this topic of growing concern.
(Renfrow & Teuton, 2008)
- Informative Style - Similar to an abstract, this style focuses on the summarizing the source. The annotation should identify the hypothesis, results, and conclusions presented by the source.
Plester, B., Wood, C, & Bell, V. (2008). Txt msg n school literacy: Does texting and knowledge of text abbreviations adversely affect children's literacy attainment? Literacy , 42(3), 137-144.
Reports on two studies that investigated the relationship between children's texting behavior, their knowledge of text abbreviations, and their school attainment in written language skills. In Study One, 11 to 12 year-old children reported their texting behavior and translated a standard English sentence into a text message and vice versa. In Study Two, children's performance on writing measures were examined more specifically, spelling proficiency was also assessed, and KS2 Writing scores were obtained. Positive correlations between spelling ability and performance on the translation exercise were found, and group-based comparisons based on the children's writing scores also showed that good writing attainment was associated with greater use of texting abbreviations (textisms), although the direction of this association is not clear. Overall, these findings suggest that children's knowledge of textisms is not associated with poor written language outcomes for children in this age range.
(Beach et al., 2009)
- Evaluative Style - This style analyzes and critically evaluates the source. The annotation should comment on the source's the strengths, weaknesses, and how it relates to the overall research topic.
Amott, T. (1993). Caught in the Crisis: Women in the U.S. Economy Today . New York: Monthly Review Press.
A very readable (140 pp) economic analysis and information book which I am currently considering as a required collateral assignment in Economics 201. Among its many strengths is a lucid connection of "The Crisis at Home" with the broader, macroeconomic crisis of the U.S. working class (which various other authors have described as the shrinking middle class or the crisis of de-industrialization).
(Papadantonakis, 1996)
- Indicative Style - This style of annotation identifies the main theme and lists the significant topics included in the source. Usually no specific details are given beyond the topic list .
Example:
Gambell, T.J., & Hunter, D. M. (1999). Rethinking gender differences in literacy. Canadian Journal of Education , 24(1) 1-16.
Five explanations are offered for recently assessed gender differences in the literacy achievement of male and female students in Canada and other countries. The explanations revolve around evaluative bias, home socialization, role and societal expectations, male psychology, and equity policy.
(Kerka & Imel, 2004)
Beach, R., Bigelow, M., Dillon, D., Dockter, J., Galda, L., Helman, L., . . . Janssen, T. (2009). Annotated Bibliography of Research in the Teaching of English. Research in the Teaching of English, 44 (2), 210-241. Retrieved from http://www.jstor.org/stable/27784357
Kerka, S., & Imel, S. (2004). Annotated bibliography: Women and literacy. Women's Studies Quarterly, 32 (1), 258-271. Retrieved from http://search.proquest.com/docview/233645656?accountid=2909
Papadantonakis, K. (1996). Selected Annotated Bibliography for Economists and Other Social Scientists. Women's Studies Quarterly, 24 (3/4), 233-238. Retrieved from http://www.jstor.org/stable/40004384
Renfrow, T.G., & Teuton, L.M. (2008). Schoolyard bullying: Peer victimization an annotated bibliography. Community & Junior College Libraries, 14(4), 251-275. doi:10.1080/02763910802336407
- << Previous: Formatting Citations
- Next: Sample Annotated Bibliographies >>
- Last Updated: Feb 27, 2023 10:50 AM
- URL: https://guides.libraries.uc.edu/annotated_bibliography
University of Cincinnati Libraries
PO Box 210033 Cincinnati, Ohio 45221-0033
Phone: 513-556-1424
Contact Us | Staff Directory
University of Cincinnati
Alerts | Clery and HEOA Notice | Notice of Non-Discrimination | eAccessibility Concern | Privacy Statement | Copyright Information
© 2021 University of Cincinnati

Spring @GetMapping and @PostMapping
Learn to create Spring WebMVC REST controllers with @Controller annotation and map HTTP requests with annotations like @RequestMapping , @GetMapping and @PostMapping .
1. Request Mapping Annotations
Spring 4.3 introduced 5 new and more specific annotations for each HTTP request type .
- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
Before Spring 4.3 , Spring had only @RequestMapping annotation for mapping all the incoming HTTP request URLs to the corresponding controller methods.
For example, in the given below code, @RequestMapping annotation has been used to map the same HTTP requests. Notice that we have specified the HTTP request type (GET, POST) as the annotation attribute method .
2. Spring @GetMapping Example
- The @GetMapping annotation is a composed version of @RequestMapping annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET) .
- The @GetMapping annotated methods handle the HTTP GET requests matched with the given URI expression.
Let us understand how to write controller methods mapped with @GetMapping annotations. In the following example, we are mapping two GET requests:
- HTTP GET /users – returns all the users in the system.
- HTTP GET /users/{id} – returns a user by specified id.
3. Spring @PostMapping Example
- The @PostMapping is a specialized version of @RequestMapping annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.POST) .
- The @PostMapping annotated methods handle the HTTP POST requests matched with the given URI expression.
- As a best practice, always specify the media types (XML, JSON etc.) using the ‘consumes’ and ‘produces’ attributes.
Let us understand how to write controller methods mapped with @PostMapping annotations. In the following example, we are mapping a POST request:
- HTTP POST /users – creates a new user in the system.
4. Annotation Attributes
All request mapping annotations support the following attributes, but they should be used when appropriate for the request type:
- path or value : specifies the mapping URI. A handler method that is not mapped to any path explicitly is effectively mapped to an empty path.
- consumes : consists of one or more media types, one of which must match the request Content-Type header.
- produces : consists of one or more media types one of which must be chosen via content negotiation against the “acceptable” media types, generally extracted from the "Accept" header but may be derived from query parameters.
- headers : specifies the headers of the mapped request, narrowing the primary mapping, with a request only mapped if each such header is found to have the given value.
- name : Assign a name to the mapping.
- params : specifies the parameters of the mapped request, narrowing the primary mapping, with a request only mapped if each such parameter is found to have the given value.
5. Class-level Shared Attributes
The mapping annotations such as @RequestMapping, @GetMapping and @PostMapping , inherit the annotation attribute values from the @RequestMapping annotation applied at the @RestController class.
In HomeController , the @RequestMapping annotation at the top specifies the produces attribute to MediaType.APPLICATION_JSON_VALUE , so all the handler methods in this class, by default, will return the JSON response.
Note that the method-level mapping annotation may override the attribute values by providing its own values. In the following example, the /members API overrides the produces attribute so it will return the XML response to the clients.
6. Difference between @PostMapping and @RequestMapping
As noted above @PostMapping annotation is one specialized version of @RequestMapping annotation that handles only the HTTP POST requests .
@PostMapping = @RequestMapping(method = { RequestMethod.POST })
Let’s see the difference between @PostMapping and @RequestMapping annotations with a very simple example. Both versions in the given example will work exactly the same. They just have a slightly different syntax.
In other words, @PostMapping acts as a shortcut for @RequestMapping(method = RequestMethod.POST) . We can see the source code of the @PostMapping annotation which internally uses the @RequestMapping annotation.
Spring MVC has made writing request handlers / REST controller classes and methods very easy. Just add a few annotations like @GetMapping and @PostMapping and put the class where component scanning can find them and configure them in the web application context.
It is also very easy to create attributes at the class level so that all handler methods inherit them by default and can override them when needed.
Same way, you can use other request mapping annotations e.g. @PutMapping , @DeleteMapping and @PatchMapping .
Happy Learning !!
Sourcecode on Github
Related posts:
- Spring MVC and Hibernate CRUD Example
- Spring DispatcherServlet – how it works?
- Spring Web MVC Tutorials
- Spring Boot and Angular Application Example
Leave a Reply
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.
Tutorial Series
Privacy Policy
REST API Tutorial

Apple is hiring: Annotation Associate role for fresher candidate with 0-1 year of experience
Deepak tamang.
- March 18, 2023
- No Comments
Apple is hiring: Annotation Associate role for fresher candidate. BA,BCOM,BSC,BBA,BBM candidate can apply for these post.
Table of Contents
Complete details are given below:-
- Company – Apple
- Roles – Annotation Associate
- Qualification – BA,BCOM,BSC,BBA,BBM
- Location – Hyderabad
- Work Experience – Fresher
- Salary – 4 LPA – 6 LPA
ABOUT THE COMPANY
Apple is an American multinational technology company headquartered in Cupertino, California. The company designs, develops, and sells consumer electronics, computer software, and online services. Apple is known for its innovative products, including the iPhone, iPad, Mac computers, Apple Watch, and Apple TV.
Apple was founded in 1976 by Steve Jobs, Steve Wozniak, and Ronald Wayne. The company’s first product was the Apple I computer, which was designed and hand-built by Wozniak. The Apple II, released in 1977, was the company’s first mass-produced product and helped establish Apple as a major player in the computer industry.
In 1984, Apple released the Macintosh computer, which featured a graphical user interface and a mouse, making it easier for users to interact with the computer. The Macintosh was a significant milestone in the history of personal computing and helped establish Apple’s reputation for innovation and design.
In 2001, Apple released the iPod, which revolutionized the music industry by making it easy to carry thousands of songs in a small, portable device. The company followed up with the iPhone in 2007, which combined a mobile phone with the functionality of an iPod and a touch screen interface.
Today, Apple is one of the largest companies in the world, with a market capitalization of over $2 trillion. The company’s products and services are used by millions of people around the world, and Apple has a reputation for high-quality design and user experience.

What you will be doing as an Annotation Associate job ?
- Reviewing and annotating data to ensure accuracy and completeness.
- Creating and maintaining data records and databases.
- Analyzing data sets to identify patterns and trends.
- Collaborating with other team members to ensure quality and consistency of data.
- Developing and implementing processes to improve data annotation and management.
- Working with cross-functional teams to develop solutions for data-related challenges.
- Staying up-to-date with the latest industry trends and technologies related to data annotation and management.
- Providing feedback to improve data quality and efficiency.
- Communicating data-related insights and findings to stakeholders.
- Maintaining data privacy and security in accordance with company policies and industry standards.
QUALIFICATION & SKILLS REQUIRED
- Experience in content review or a similar environment
- Excellent English reading, writing and comprehension skills
- Excellent active listening skills with the ability to understand verbal nuances
- Ability to independently navigate a technical environment
- Excellent typing skills
- Highly organized with strong attention to detail and excellent proofreading skills
- Flexibility to respond and support changing priorities quickly and efficiently
- Grows with a team where expertise is shared and feedback is welcomed
- Knowledge of one or more of the following: iOS, PC or Mac experience and Siri preferred
How To Apply For Apple Recruitment 2023 ?
To apply for the Apple Recruitment 2023 , interested candidates must follow the procedure outlined below:
- Click on the “Apply here” button provided below. You will be redirected to the company official career page.
- Click on “Apply Online”.
- If you have not registered before, create an account.
- After registration, login and fill in the application form with all the necessary details.
- Submit all relevant documents, if requested (e.g. resume, mark sheet, ID proof).
- Provide accurate information in your application.
- Verify that all the details entered are correct.
- Submit the application process after verification.
INTERESTED CANDIDATES CAN APPLY THROUGH THE BELOW LINK
Apple recruitment – frequently asked question.
What is Apple Selection Process?
The selection process will be based on a Written test followed by Technical and HR interviews.
What is the average salary at Apple for freshers?
The average of 4 LPA – 6 LPA is based on the reports of Glassdoor and Ambition Box.
The Recruitment Information Provided above is for Informational Purposes only . The above Recruitment Information has been taken from the official site of the Organization. We do not provide any Recruitment guarantee. Recruitment is to be done as per the official recruitment process of the company. We don’t charge any fee for providing this job Information.
“Join the Team: Morgan Stanley is Hiring for Fund Accounting Positions”

“Become a Financial Reporting Analyst at Wells Fargo – Apply Now”
Latest jobs.

Genpact is hiring Account Payable Associate/Process Developer 2023

Get Hired by TCS through the National Qualifier Test: Apply Now

Become a part of Citi Bank as a Fund Accounting Analyst 1 and Financial Planning and Analysis professional

Clariant is Hiring General Accounting Specialist with 2-5 years of experience

Start Your Career with HP – Apply for Internship Positions Today

Join the Talent Acquisition Team at IDFC Bank: Apply Now

Walk-in Interviews for HR Recruiter Positions at Varun Beverages
Who we are.
jobsforcommerce.com is a Platform where you will get job opening from Various MNC’S located Across India.
Request For Post
© 2022 ALL RIGHTS RESERVED
DESIGNED BY jobsforcommerce.com

IMAGES
VIDEO
COMMENTS
The @RequestBody annotation is applicable to handler methods of Spring controllers. This annotation indicates that Spring should deserialize a request body into an object. This object is passed as a handler method parameter. Under the hood, the actual deserialization is done by one of the many implementations of MessageConverter.
"Annotation Processing" is a hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then (by producing compiler errors, compiler warning, emitting source code, byte code ...). API reference: javax.annotation.processing (Java Platform SE 6). Share Improve this answer Follow
Overview In this quick tutorial, we'll explore Spring's @RequestParam annotation and its attributes. Simply put, we can use @RequestParam to extract query parameters, form parameters, and even files from the request. Further reading: Spring @RequestMapping New Shortcut Annotations
Turn off annotation. As the presenter, you can turn off annotation for all participants by selecting Stop annotation in the meeting controls at the upper-middle area of your screen. Troubleshooting. If you don't see the option to use annotation in a meeting: 1. In the upper-right corner of Teams, select Settings and more > Settings > General. 2.
This annotation indicates that a method argument is bound to a URI template variable. We can specify the URI template with the @RequestMapping annotation and bind a method argument to one of the template parts with @PathVariable. We can achieve this with the name or its alias, the value argument:
The @RequestMapping annotation can be applied to class-level and/or method-level in a controller. The class-level annotation maps a specific request path or pattern onto a controller. You can then apply additional method-level annotations to make mappings more specific to handler methods.
Annotation for mapping web requests onto methods in request-handling classes with flexible method signatures. Both Spring MVC and Spring WebFlux support this annotation through a RequestMappingHandlerMapping and RequestMappingHandlerAdapter in their respective modules and package structure. For the exact list of supported handler method arguments and return types in each, please use the ...
Request Mapping Annotation in Spring Boot @RequestMapping is a class level (also called type level) and method level annotation, it is used to process HTTP requests with specified URL patterns. It is used in and along with both @Controller and @RestController. 1. How @RequestMapping annotation it is used?
annotation is when used to map Spring MVC controller methods. Request Mapping Basics In Spring MVC applications, the RequestDispatcher (Front Controller Below) servlet is responsible for routing incoming HTTP requests to handler methods of controllers.
The @RequestMapping annotation is a versatile tool. See it used to configure traditional web page requests as well as RESTFul web services in Spring MVC.
Defender for DevOps exposes security findings as annotations in Pull Requests (PR). Security operators can enable PR annotations in Microsoft Defender for Cloud. Any exposed issues can then be remedied by developers. This process can prevent and fix potential security vulnerabilities and misconfigurations before they enter the production stage.
Annotation that can be used to associate the part of a "multipart/form-data" request with a method argument. Supported method argument types include MultipartFile in conjunction with Spring's MultipartResolver abstraction, jakarta.servlet.http.Part in conjunction with Servlet multipart requests, or otherwise for any other method argument, the content of the part is passed through an ...
The @GET annotation on the getWidgetList method indicates that the method is a resource method that you want to be called when an HTTP GET request is dispatched for that URI. Additional annotations are provided to support the other common HTTP methods. The set is extensible for other less common methods.
Spring - MVC RequestParam Annotation. @RequestParam annotation enables spring to extract input data that may be passed as a query, form data, or any arbitrary custom data. Here, we will see how we can use @RequestParam when building RESTful APIs for a web-based application. Context of the Application: Let us suppose we are implementing a ...
Spring RestController annotation is a convenience annotation that is itself annotated with @Controller and @ResponseBody. This annotation is applied to a class to mark it as a request handler. Spring RestController annotation is used to create RESTful web services using Spring MVC. Spring RestController takes care of mapping request data to the ...
Annotations are comments, notes, explanations, or other types of external remarks that can be attached to a Web document or to a selected part of a document. As they are external, it is possible to annotate any Web document independently, without needing to edit the document itself. From a technical point of view, annotations are usually seen ...
Annotation indicating a method parameter should be bound to the body of the web request. The body of the request is passed through an HttpMessageConverter to resolve the method argument depending on the content type of the request. Optionally, automatic validation can be applied by annotating the argument with @Valid.
An annotation is a brief note following each citation listed on an annotated bibliography. The goal is to briefly summarize the source and/or explain why it is important for a topic. They are typically a single concise paragraph, but might be longer if you are summarizing and evaluating.
3. Spring @PostMapping Example. The @PostMapping is a specialized version of @RequestMapping annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.POST).; The @PostMapping annotated methods handle the HTTP POST requests matched with the given URI expression.; As a best practice, always specify the media types (XML, JSON etc.) using the 'consumes' and 'produces ...
Apple is an American multinational technology company headquartered in Cupertino, California. The company designs, develops, and sells consumer electronics, computer software, and online services. Apple is known for its innovative products, including the iPhone, iPad, Mac computers, Apple Watch, and Apple TV. Apple was founded in 1976 by Steve ...