본문 바로가기

form3

Spring Web MVC - Attributes, 멀티 폼 서브밋 Spring Web MVC 009 - 핸들러 메소드 3 SessionAttributes 모델 정보를 HTTP 세션에 저장해주는 어노테이션이다. 먼저 HttpSession 을 보자. 핸들러 메소드의 아규먼트로 받아와서 세션을 관리할 수 있게 도와주는 객체이다. 상대적으로 low 레벨 단위의 코딩을 할 수 있다. @GetMapping("/news/form") public String newsForm(Model model, HttpSession httpSession) { News news = new News(); news.setLimit(10); model.addAttribute("news", news); // 세션안에 news 라는 이름으로 객체를 넣어준다. httpSession.setAttribute("n.. 2021. 2. 21.
Spring Web MVC - Handler 아규먼트 다루기 Spring Web MVC - 핸들러 메소드 핸들러 메소드에서 다양한 아규먼트를 사용할 수 있다. 핸들러 메소드 아규먼트 설명 WebRequest NativeWebRequest ServletRequest/Reponse HttpServletRequest/Reponse 요청 또는 응답 객체에 접근 가능한 API InputStream Reader OutputStream Writer 요청 본문을 읽어 오거나, 응답 본문을 쓸 때 사용할 수 있는 API PushBuilder Spring 5에 추가됨. HTTP/2에서 사용할 수 있다. 리소스 푸쉬에 사용된다. 일반적으로 일어나는 HTTP 요청 : 1 클라이언트가 뷰 요청 2 서버 응답 (이 때 뷰에 다른 리소스 자원이 있어서 불러오고 싶음) 3 클라이언트가 이미지.. 2021. 2. 17.
Django 앱 작성하기 part4 [form] 투표(vote) 양식 만들기 반영사항- POST 데이터를 처리한 후에는 항상 HttpResponseRedirect를 반환해야 한다. polls/views.py from django.shortcuts import get_object_or_404, render def results(request, question_id): question = get_object_or_404(Question, pk=question_id) return render(request, 'polls/results.html', {'question': question}) polls/templates/polls/results.html {{ question.question_text }} {% for choice in question.choic.. 2019. 7. 12.
728x90