Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.ignite.controller; import com.ignite.dao.AccountDao; import com.ignite.dao.ClientDao; import com.ignite.domain.Account; import com.ignite.domain.Client; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.annotation.Secured; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; @Controller public class TellerController { @Autowired ClientDao clientDao; @Autowired AccountDao accountDao; @RequestMapping(value = "/teller", method = RequestMethod.GET) public ModelAndView clients() { List<Client> clients = clientDao.getClients(); ModelAndView mav = new ModelAndView("teller"); mav.addObject("clientList", clients); return mav; } @RequestMapping(value = "/teller/client/{clientName}", method = RequestMethod.GET) public ModelAndView clients(@PathVariable String clientName) { Client client = clientDao.getClient(clientName); List<Account> accounts = accountDao.getAccountsForClient(client); ModelAndView mav = new ModelAndView("clientDetail"); mav.addObject("client", client); mav.addObject("accountList", accounts); return mav; } }