I have the method:
public List<IEntity> wordsCollection()
I need to create the bean with that list. This method ask DB for data and gets it out. When I used method call - I do call several times. But I need the bean with that value. How can I do this?
I need something like this:
<util:list id ="wc">
value = collections.wordsCollection
</util:list>
You can use @PostConstruct
to load the data in your spring bean
The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization.
public class SomeService{
@PostConstruct
public void loadCollection() throws Exception {
wordsCollection();
}
}
Inject your dao in the spring bean and call the required method in the postconstruct method.
you can store the retrived list in the session and reuse it among spring controllers when required. Otherwise you can use Spring's expression language(SpEL).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.