java - How to access bean from controller in Spring MVC? -


i have bean

<bean class="myprogram.filelist"> 

defined.

now wish bean accessible jsp. how accomplish this?

first thought access bean somewhere in controller method , put model

@requestmapping(value = "/", method = requestmethod.get) public string home(locale locale, model model) {     logger.info("welcome home! client locale {}.", locale);      filelist filelist = // code access filelist bean      model.addattribute("filelist", filelist);      return "home"; } 

but ether not required or can described somewhere in bean configuration?

update

the answer exposedcontextbeannames parameter.

first of all, inject bean controller using @autowired annotation:

@autowired private filelist filelist; 

then add model did: model.addattribute("filelist", filelist);.

in jsp use jstl access it. e.g:

some property file list bean: <c:out value="${filelist.someproperty}"/> 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -