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 | 29 | 
| 30 | 
                            Tags
                            
                        
                          
                          - 프로젝트 후기
- 간단 프로젝트
- 뷰
- 자바
- IT시스템개발
- 백준
- 뷰 리액트 비교
- react
- 첫 React
- SBS 본사
- 사내시스템
- 백준알고리즘
- Vue.js
- 첫 리액트
- 뷰 리액트
- 리액트
- 면접
- 웹 개발 면접 질문
- e-HR
- MySQL
- 경력직
- SBS 개발
- 알고리즘
- 대문자
- 1차면접
- 오라클
- 트리
- CompositionAPI
- 쟈스
- URL입력
                            Archives
                            
                        
                          
                          - Today
- Total
리주의 프로그래밍 공부
POST 입력 본문
1. 콤보박스
@Controller 와 @RequestMapping 된 클래스의 내부
	@RequestMapping("reg")
	@ResponseBody
	public String reg(String title, String content, String category) {
		
		return String.format("title:%s<br>content:%s<br>category:%s", title, content, category);
	}콤보박스에서 입력받은 값들이 category로 넘겨받아 한줄로 출력된다.
다만, 콤보박스에서 value값이 없다면, 콤보박스의 이름이 전달된다.

2. 체크박스
@Controller 와 @RequestMapping 된 클래스의 내부
	@RequestMapping("reg")
	@ResponseBody
	public String reg(String title, String content, String category, String[] foods) {
		System.out.println(category);
        //체크박스에서 받은 값들을 console에 출력
		for(String food : foods)
			System.out.println(food);
		
		return String.format("title:%s<br>content:%s<br>category:%s", title, content, category);
	}체크박스에 같은 name으로 오는 여러개의 값들은 배열로 받을 수 있다.
이 경우에는 String[] foods로 값을 넘겨받는다.

3. 라디오버튼
@Controller 와 @RequestMapping 된 클래스의 내부
@RequestMapping("reg")
	@ResponseBody
	public String reg(String title, String content, String category, String[] foods, String food) {
		System.out.println(category);
		for(String f : foods)
			System.out.println(f);
		
		return String.format("title:%s<br>content:%s<br>category:%s<br>food:%s", title, content, category, food);
	}선택된 값이 food로 넘겨져 출력된다.

위 내용은 유튜브 뉴렉처 님의 스프링 MVC 40, 41강 강의영상을 보고 개인적으로 작성한 글입니다.
'스프링(Spring) 공부' 카테고리의 다른 글
| 파일 업로드 설정하기 (0) | 2021.01.17 | 
|---|---|
| POST 한글깨짐 해결 (0) | 2021.01.16 | 
| QueryString 입력 (0) | 2021.01.13 | 
| JSON 출력 (0) | 2021.01.12 | 
| RestController (0) | 2021.01.12 | 
 
           
                  