Questions tagged [spring-3]

Version 3.x of the Spring Framework, use [tag:spring] for general Spring related questions.

The Spring Framework is an open source application framework for the Java platform. Use for general Spring related questions. This tag is for questions that are specific to versions 3.x only.

It provides services and functionality across the application domain, including a core Inversion of Control container, technology-agnostic data-access and MVC layers, extensive AOP support, task scheduling, and various integration patterns designed to make distributed system development simpler and clearer. While some spring modules are simple wrappers and helpers over the Java EE specifications, the majority of them go far beyond the Java EE specification.

The latest Spring Framework Reference Documentation can be found here.

Frequently Asked Questions

People often ask about the following Spring topics:

###Guides:

Video tutorial on Spring Framework

###Blog:

Related tags

###More information:

762 questions
721
votes
15 answers

Difference between and

I'm learning Spring 3 and I don't seem to grasp the functionality behind and . From what I've read they seem to handle different annotations (@Required, @Autowired etc vs @Component, @Repository,…
user938214097
  • 7,211
  • 3
  • 14
  • 3
350
votes
3 answers

Understanding Spring @Autowired usage

I am reading the spring 3.0.x reference documentation to understand Spring Autowired annotation: 3.9.2 @Autowired and @Inject I am not able to understand the below examples. Do we need to do something in the XML for it to work? EXAMPLE 1 public…
NewQueries
  • 4,841
  • 11
  • 33
  • 39
219
votes
4 answers

When use ResponseEntity and @RestController for Spring RESTful applications

I am working with Spring Framework 4.0.7, together with MVC and Rest I can work in peace with: @Controller ResponseEntity For example: @Controller @RequestMapping("/person") @Profile("responseentity") public class…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
157
votes
3 answers

What's the difference between and in servlet?

I am migrating from Spring 2.5 to Spring 3. They have introduced which does some black magic. This is expected to be declared in servlet configuration file only. In Spring 2.5 I have just used
glaz666
  • 8,707
  • 19
  • 56
  • 75
117
votes
6 answers

How to get a method's annotation value from a ProceedingJoinPoint?

I have below annotation. MyAnnotation.java @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation { } SomeAspect.java public class SomeAspect{ @Around("execution(public * *(..)) &&…
user755806
  • 6,565
  • 27
  • 106
  • 153
67
votes
2 answers

How to register Spring @Configuration annotated class instead of applicationContext.xml file in web.xml?

I am using jsf and spring together in web application. I have configured datasource and session factory in one configuration class which uses annotations like @Configuration, @ComponentScan etc. I don't have any applicationContext.xml file in my…
Mital Pritmani
  • 4,880
  • 8
  • 38
  • 39
59
votes
5 answers

How to set 'Content-Disposition' and 'Filename' when using FileSystemResource to force a file download file?

What is the most appropriate, and standard, way to set the Content-Disposition=attachment and filename=xyz.zip using Spring 3 FileSystemResource? The action looks like : @ResponseBody @RequestMapping(value = "/action/{abcd}/{efgh}", method =…
Hassan Jamil
  • 1,270
  • 1
  • 11
  • 15
57
votes
6 answers

Add attributes to the model of all controllers in Spring 3

Every single view in my Spring 3 app has a set of attributes they can rely on. So the first line of every controller is something like: ControllerHelper.addDefaultModel(model, personManager, request); In there I'll add user object and full name…
at.
  • 50,922
  • 104
  • 292
  • 461
56
votes
2 answers

When use AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer?

I am working with Spring 4.0.7 I did a research about configure Spring MVC through JavaConfig. Practically until yesterday I have seen two configurations using these two options extends AbstractAnnotationConfigDispatcherServletInitializer extends…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
55
votes
11 answers

Encoded slash (%2F) with Spring RequestMapping path param gives HTTP 400

This is not a duplicate referenced question, because it is Spring specific. Whoever added that (3 years after the fact!) didn't bother to read the question or comment thread to see what the real answer was. The accepted answer isn't quite the…
Jim
  • 3,476
  • 4
  • 23
  • 33
53
votes
2 answers

Benefits of JavaConfig over XML configurations in Spring?

Earlier the configurations used to be in hard coded in the code, later it was externalized to .property files (for sake of avoiding hard coded values, avoiding changing code for the sake of changing configurations..etc) then it moved to XML (for…
yathirigan
  • 5,619
  • 22
  • 66
  • 104
42
votes
7 answers

EJB 3.1 or Spring 3.. When to choose which one?

EJB achieved many improvements in 3.x versions, Spring is also commonly used and version 3 is a good alternative. There are many articles on web, but no exact comparison about ejb3x versus spring3x.. Do you have any ideas about them, in real world…
asyard
  • 1,743
  • 5
  • 21
  • 43
41
votes
3 answers

Multiple scenarios @RequestMapping produces JSON/XML together with Accept or ResponseEntity

I am working with Spring 4.0.7 About Spring MVC, for research purposes, I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public…
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
35
votes
6 answers

Can @PathVariable return null if it's not found?

Is it possible to make the @PathVariable to return null if the path variable is not in the url? Otherwise I need to make two handlers. One for /simple and another for /simple/{game}, but both do the same just if there is no game defined i pick first…
Rihards
  • 10,241
  • 14
  • 58
  • 78
33
votes
7 answers

@EnableTransactionManagement annotation with 2 transaction managers

I am using @Configuration annotation for configuration of spring instead of xml file. I am configuring 2 datasources with different session factory and different transaction managers. I am stuck with a problem here for @EnableTransactionManagement…
Mital Pritmani
  • 4,880
  • 8
  • 38
  • 39
1
2 3
50 51