SpringMVC

3,565 views
3,463 views

Published on

知っ得納得Webフレームワーク勉強会のスライド

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,565
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
77
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

SpringMVC

  1. 1. -Weapons for the War on Java Complexity -
  2. 2.   id:c9katayama 
  3. 3. AgendaSpringMVC
  4. 4. SpringMVCSpring Web
  5. 5. SpringMVCSpring1.0,JDK1.4 Apache License2.0SpringSource
  6. 6. SpringMVC
  7. 7. SpringMVCDispatcher HandlerServlet view
  8. 8. SpringMVC  DispatcherServlet Dispatcher  Spring HandlerServlet WebApplicationContext view
  9. 9. SpringMVC  HandlerMappingDispatche HandlerServlet  Handler  URL URL view
  10. 10. SpringMVCDispatche HandlerServlet  HandlerAdapter  Handler view  Handler
  11. 11. SpringMVCDispatcher HandlerServlet  Handler  Struts Action view 
  12. 12. SpringMVC  ModelAndViewDispatche  Model View HandlerServlet view
  13. 13. SpringMVCDispatche  view HandlerServlet  JSP HTML  view
  14. 14. SpringMVC   
  15. 15. SpringMVC
  16. 16. SpringMVC
  17. 17. SpringMVCHandler
  18. 18. SpringMVC  
  19. 19. SpringMVC  Spring2.5
  20. 20. SpringMVC
  21. 21. SpringMVC DefaultAnnotationHandlerMappingSpring Handler RequestMapping URL Handler
  22. 22. SpringMVC AnnotationMethodHandlerAdapterHandlerMapping Handler RequestMapping HTTP
  23. 23. SpringMVCDefaultAnnotationHandlerMappingAnnotationMethodHandlerAdapter DispatcherServlet
  24. 24. SpringMVCAnnotationMethodHandlerAdapter HandlerHandlerPOJO MVC
  25. 25. SpringMVCHandler
  26. 26. SpringMVC@Controller@RequestMapping("/login.do")public class LoginController { @RequestMapping(method = RequestMethod.GET) public String setup(Model model) { model.addAttribute(new LoginForm()); return "login.jsp"; } @RequestMapping(method = RequestMethod.POST) public String doLogin(LoginForm loginForm, Errors errors) { if (errors.hasErrors()) { return "login.jsp"; }else{ return “redirect:menu.do”; } }}
  27. 27. SpringMVC@Controller  
  28. 28. SpringMVCpackage sample.springmvc.controller@Controllerpublic class LoginController {
  29. 29. SpringMVC@RequestMapping   
  30. 30. SpringMVC@Controller@RequestMapping("/login.do")public class LoginController { @RequestMapping(method = RequestMethod.GET) public String setup(Model model) { model.addAttribute(new LoginForm()); return "login.jsp"; } @RequestMapping(params=”character=EEDA”) public String character() { return “character.jsp” }
  31. 31. SpringMVC@Controlle @RequestMapping
  32. 32. SpringMVCHandler
  33. 33. SpringMVC 
  34. 34. SpringMVC      
  35. 35. SpringMVC      
  36. 36. SpringMVCModel    @RequestMapping(method = RequestMethod.GET) public String setup(Model model) { model.addAttribute(new LoginForm()); return "login.jsp"; } loginForm
  37. 37. SpringMVC  SessionAttributes  
  38. 38. SpringMVC@SessionAttributes 
  39. 39. SpringMVC@Controller@RequestMapping("/login.do")@SessionAttributes(“loginForm”)public class LoginController { @RequestMapping(method = RequestMethod.GET) public String setup(Model model) { model.addAttribute(“loginForm”,new LoginForm()); return "login.jsp"; } loginForm
  40. 40. SpringMVC@Controller@RequestMapping("/login.do")@SessionAttributes(“loginForm”)public class LoginController { @RequestMapping(method = RequestMethod.POST) public String doEnd(SessionStatus status) { status.setComplete(); return "login.jsp"; loginForm }
  41. 41. SpringMVC  
  42. 42. SpringMVC/sample/login.do?id=hoge@RequestMapping(method = RequestMethod.POST)public String doLogin(@RequestParam(“id”) String id) { //id ”hoge”}
  43. 43. SpringMVC  
  44. 44. SpringMVC@RequestMapping(method = RequestMethod.POST)public String doLogin(LoginForm loginForm, Errors errors) {}@RequestMapping(method = RequestMethod.POST)public String doLogin( @ModelAttribute(“loginForm”)LoginForm loginForm, Errors errors) {}
  45. 45. SpringMVC 
  46. 46. SpringMVC@RequestMapping(method = RequestMethod.POST)public String doLogin(LoginForm loginForm, Errors errors) { if (errors.hasErrors()) { return "login.jsp"; }else{ return “redirect:menu.do”; }}
  47. 47. SpringMVC   
  48. 48. SpringMVC     
  49. 49. SpringMVCview
  50. 50. SpringMVC  
  51. 51. SpringMVC<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %><form:form modelAttribute="loginForm"> ID: <form:errors path="id"/> <form:input path="id" size="30" maxlength="30"/> PASSWORD: <form:errors path="password"/> <form:password path="password" size="10" maxlength="10"/> <input type="submit" value="login"/></form:form>
  52. 52. SpringMVC
  53. 53. SpringMVC     
  54. 54. SpringMVC    
  55. 55. SpringMVC   

×