Most of you probably will say that I should use google for this problem, since it's quite simple, but I can't find a truly correct solution that works.
I have two session-scoped models: Playlist
and Track
. As you can guess, playlist contains a list of tracks:
@Component
public class Playlist {
String name;
List<Track> tracklist;
@Component
public class Track {
int duration;
String artist;
I use @Autowired
annotation in controllers to get the playlist. In the first controller I set the attributes of Playlist, in the second one I get them. Everything works fine with the name
attribute of Playlist, but tracklist
is null. I know that I must use something like @Resource
or @Qualifier
, but I don't understand how to make this annotations works. Simply writing
@Resource
private List<Track> tracks;
does not seems to work.
In my servlet-context.xml
the two beans are declared like this:
<bean id="track" class="com.foo.bar.models.Track" scope="session">
<aop:scoped-proxy/>
</bean>
<bean id="playlist" class="com.foo.bar.models.Playlist" scope="session">
<aop:scoped-proxy/>
</bean>
I've already look this Spring autowire a list but did not help me, since tracks are not declared via .xml but setted in a controller.