1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| package mo.tongxue.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import mo.tongxue.domain.Account; import mo.tongxue.service.impl.AccountServiceImpl;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List;
@Controller @RequestMapping("/account") public class AccountController { @Autowired AccountServiceImpl accountService; @RequestMapping("/findAll") public String findAll(Model model){ System.out.println("表现层的findAll方法执行了"); List<Account> list = accountService.findAll(); model.addAttribute("list",list); return "list"; }
@RequestMapping("/save") public void save(Account account, HttpServletRequest request, HttpServletResponse response) throws IOException { accountService.saveAccount(account); response.sendRedirect(request.getContextPath()+"/account/findAll"); return ; } }
|