Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to pass variables from java to jsp in Spring
    text
    copied!<p>in a spring framework I want to pass some variables(objects) to jsp page. I can pass one object with:</p> <pre><code> ModelAndView modelAndView= new ModelAndView("JspPageName", "message", message); return message </code></pre> <p>But how can I send more than one objects from java to jsp. Actually I know that I can make a object array and send this array, however I wonder the best way of doşng this My code which send the datas to jsp is this:</p> <pre><code>@Controller public class DomainEkleController { private DomainJDBCTemplate domainJDBCTemplate; private MemurJDBCTemplate memurJDBCTemplate; @ModelAttribute("Domain") public Domain getDomain() { return new Domain(); } @Autowired @Qualifier("domainJDBCTemplate") public void setDomainJDBCTemplate(DomainJDBCTemplate domainJDBCTemplate) { this.domainJDBCTemplate = domainJDBCTemplate; } @Autowired @Qualifier("memurJDBCTemplate") public void setMemurJDBCTemplate(MemurJDBCTemplate memurJDBCTemplate) { this.memurJDBCTemplate = memurJDBCTemplate; } @RequestMapping(value="/DomainEkle") public ModelAndView domainEkle() { List&lt;Memur&gt; memurlar=memurJDBCTemplate.getAll(); System.out.println(memurlar); /*for(Memur x:memurlar) { System.out.println(x.getIsim()); }*/ String message = "Hello World, Spring 3.0!"; ModelAndView domain_ekle= new ModelAndView("DomainEkle", "message", message); return domain_ekle; } @RequestMapping(value="/DomainEkle",method=RequestMethod.POST) public ModelAndView domain_eklendi_fonksiyon(@ModelAttribute("Domain")Domain domain, ModelMap model) { model.addAttribute("domain_adi", domain.getDomain_adi()); model.addAttribute("sunucu_no", domain.getSunucu_no()); model.addAttribute("tarih", domain.getTarih()); model.addAttribute("ilgili_memur_no",domain.getIlgili_memur_no()); String message="Domain Kaydi Yapilmistir!"; ModelAndView dm_eklendi=new ModelAndView("DomainEkle","message",message); domainJDBCTemplate.addDomain(domain); return dm_eklendi; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload