Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 오라클
- 정처기필기
- cisco packet
- 정보처리기사
- VLAN
- 자바
- 리눅스
- 원형그래프
- NCS
- 네트워크
- html
- ciscopacket
- rinux
- w3school
- jsp연결
- 참조타입
- Java
- 데이터베이스
- autoset
- sql
- 네트워크관리사
- php
- 버추얼머신
- javaee
- Cisco
- jsp
- ospf
- 라우터
- 이것이 자바다
- Oracle
Archives
- Today
- Total
기록해! 정리해!
어노테이션 기반 MVC 개발 - @ModelAttribute 사용 본문
package com.springbook.view;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.springbook.biz.user.UserVo;
import com.springbook.biz.user.impl.UserDao3;
@Controller
public class LoginController {
@RequestMapping(value="/login.do", method=RequestMethod.GET)
public String loginView(@ModelAttribute("user") UserVo vo, HttpSession session ) {
System.out.println("로그인 화면으로 이동");
vo.setId("test");
vo.setPassword("test123");
/*
session.setAttribute("id", "test");
session.setAttribute("password", "test123");
*/
return"login.jsp" ;
}
@RequestMapping(value="/login.do", method=RequestMethod.POST)
public String login(UserVo vo, UserDao3 service ) {
System.out.println("로그인 처리");
if(service.getUser(vo) != null){
return "getBoardList.do" ;
}else{
return"login.jsp" ;
}
}
@RequestMapping(value="/logout.do")
public String logout( HttpSession session) {
System.out.println("로그아웃 처리");
session.invalidate();
return "login.jsp";
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<br><br>
<h1> 로그인 </h1>
<hr />
<form action=login.do method=post>
<table border=1>
<tr><td>아이디 </td> <td>
<input type="text" name="id" value="${user.id}" > </td></tr>
<tr><td>비밀번호 </td> <td>
<input type="text" name="password" value="${user.password}" > </td></tr>
<tr><td colspan=2 align="center">
<input type="submit" value="로그인" >
</td></tr>
</table>
</form>
<hr />
</div>
</body>
</html>
'Spring' 카테고리의 다른 글
어노테이션 기반 MVC 개발 - ModelAndView 를 Model 로 변환 (0) | 2022.09.26 |
---|---|
어노테이션 기반 MVC 개발 - 요청 방식에 따른 처리 ( method 속성, vo 값 리턴 받기 ) (0) | 2022.09.26 |
어노테이션 기반 MVC 개발 - 컨트롤러 통합하기 (0) | 2022.09.26 |
어노테이션 기반 MVC 개발 (0) | 2022.09.26 |
Spring MVC 구조 - ViewResolver 적용하기 (0) | 2022.09.26 |
Comments