All Questions
Tagged with spring-mvc-initbinders or spring-mvc
58,888 questions
3938 votes
31 answers
4.8m views
How do I POST JSON data with cURL?
I use Ubuntu and installed cURL on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with cURL. I am trying to post a JSON data....
2644 votes
30 answers
1.2m views
What's the difference between @Component, @Repository & @Service annotations in Spring?
Can @Component, @Repository, and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? In other words, if I have a ...
562 votes
8 answers
474k views
When do I use path parameters vs. query parameters in a RESTful API? [closed]
I want to make my RESTful API very predictable. What is the best practice for deciding when to make a segmentation of data using the URI rather than by using query parameters? It makes sense to me ...
561 votes
30 answers
472k views
Infinite Recursion with Jackson JSON and Hibernate JPA issue
When trying to convert a JPA object that has a bi-directional association into JSON, I keep getting org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) All I found ...
495 votes
34 answers
839k views
How to solve the “failed to lazily initialize a collection of role” Hibernate exception
This is the exception: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: mvc3.model.Topic.comments, no session or session was closed Here is the model: @...
465 votes
25 answers
1.1m views
How to upload a file and JSON data in Postman?
I am using Spring MVC and this is my method: /** * Upload single file using Spring Controller. */ @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) public @ResponseBody ...
463 votes
13 answers
565k views
How to respond with an HTTP 400 error in a Spring MVC @ResponseBody method returning String
I'm using Spring MVC for a simple JSON API, with a @ResponseBody based approach like the following. (I already have a service layer producing JSON directly.) @RequestMapping(value = "/matches/{...
440 votes
15 answers
265k views
Difference between spring @Controller and @RestController annotation
Difference between spring @Controller and @RestController annotation. Can @Controller annotation be used for both Web MVC and REST applications? If yes, how can we differentiate if it is Web MVC or ...
438 votes
14 answers
459k views
What is @ModelAttribute in Spring MVC?
What is the purpose and usage of @ModelAttribute in Spring MVC?
420 votes
9 answers
563k views
@RequestParam vs @PathVariable
What is the difference between @RequestParam and @PathVariable while handling special characters? + was accepted by @RequestParam as space. In the case of @PathVariable, + was accepted as +.
396 votes
18 answers
178k views
Spring MVC @PathVariable with dot (.) is getting truncated
This is continuation of question Spring MVC @PathVariable getting truncated Spring forum states that it has fixed(3.2 version) as part of ContentNegotiationManager. see the below link. https://github....
389 votes
11 answers
869k views
Using env variable in Spring Boot's application.properties
We are working on a Spring Boot web application, and the database we are using is MySQL; the setup we have is we first test it locally (means we need to install MySQL on our PC); then we push to ...
359 votes
11 answers
622k views
Spring Boot configure and use two data sources
How can I configure and use two data sources? For example, here is what I have for the first data source: application.properties #first db spring.datasource.url = [url] spring.datasource.username = [...
336 votes
6 answers
190k views
Difference between Role and GrantedAuthority in Spring Security
There are concepts and implementations in Spring Security, such as the GrantedAuthority interface to get an authority to authorize/control an access. I would like that to permissible operations, ...
325 votes
4 answers
220k views
What exactly is Field Injection and how to avoid it?
I read in some posts about Spring MVC and Portlets that field injection is not recommended. As I understand it, field injection is when you inject a Bean with @Autowired like this: @Component public ...