Spring(MVC)_02_01

2025. 1. 22. 18:30·Spring, Boot/기초 내용 정리

2025-01-22

 

 

 

 

 

<%@ 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">
		<hr width="30%" color="gray">
			<h3>개인 정보 입력 폼 페이지</h3>
		<hr width="30%" color="gray">
		<br> <br>
		
		<form method="post" action="<%= request.getContextPath() %>/inputOk">
			<table border="1" width="350">
				<tr>
					<th>이 름</th>
					<td><input name="name"></td>
				</tr>
				
				<tr>
					<th>나 이</th>
					<td><input name="age"></td>
				</tr>
				
				<tr>
					<th>연락처</th>
					<td><input name="phone"></td>
				</tr>
				
				<tr>
					<td colspan="2" align="center">
						<input type="submit" value="전송">&nbsp;&nbsp;
						<input type="reset" value="취소">
					</td>
				</tr>
			</table>
		</form>
	</div>

</body>
</html>

 

<%@ 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">
		<hr width="30%" color="maroon">
			<h3>개인정보 내역 페이지</h3>
		<hr width="30%" color="maroon">	
		<br> <br>
		
		<table border="1" width="350">
			<tr>
				<th>이 름</th>
				<td>${ Name }</td>
			</tr>
			
			<tr>
				<th>나 이</th>
				<td>${ Age }</td>
			</tr>
			
			<tr>
				<th>연락처</th>
				<td>${ Phone }</td>
			</tr>
		</table>
	</div>

</body>
</html>

 

package com.spring.mvc02;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class MyController {

	@RequestMapping("input")
	public String input() {
		
		return "insertForm";
	}
	
	@RequestMapping("inputOk")
	public String Ok(HttpServletRequest request, Model model) {
		String user_name = request.getParameter("name").trim();
		String user_age = request.getParameter("age").trim();
		String user_phone = request.getParameter("phone").trim();
		
		model.addAttribute("Name", user_name)
			.addAttribute("Age", user_age)
			.addAttribute("Phone", user_phone);
		
		return "inputResult";
	}
}

'Spring, Boot > 기초 내용 정리' 카테고리의 다른 글

Spring(MVC)_03_01  (0) 2025.01.22
Spring(MVC)_02_02  (0) 2025.01.22
Spring(MVC)_01_03  (0) 2025.01.22
Spring(MVC)_01_02  (0) 2025.01.22
Spring(MVC)_01_01  (0) 2025.01.22
'Spring, Boot/기초 내용 정리' 카테고리의 다른 글
  • Spring(MVC)_03_01
  • Spring(MVC)_02_02
  • Spring(MVC)_01_03
  • Spring(MVC)_01_02
mw41817
mw41817
일생의 개발 기록 저장소
  • mw41817
    IT 개발 일지
    mw41817
    • Index (487)
      • HTML (36)
        • 기초 내용 정리 (36)
      • CSS (29)
        • 기초 내용 정리 (29)
      • JavaScript (60)
        • 기초 내용 정리 (60)
      • JQuery (38)
        • 기초 내용 정리 (38)
      • Java (232)
        • 기초 내용 정리 (232)
      • JSP (46)
        • 기초 내용 정리 (46)
      • Spring, Boot (31)
        • 기초 내용 정리 (31)
      • DB (5)
        • Oracle SQL (5)
      • Code WorkBook (6)
        • programmers (6)
        • Baekjoon (0)
      • 기타 (1)
        • 유용한 사이트 (3)
  • 전체
    오늘
    어제
  • 글쓰기 관리
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • 카테고리
    • 주인장 GitHub
  • 공지사항

  • 인기 글

  • 태그

    html #코딩 #프로그래밍 #기초
  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.0
mw41817
Spring(MVC)_02_01
상단으로

티스토리툴바