[스프링] UriComponentsBuilder 사용하기

2022. 10. 18. 19:39· 기존(310)/🏀Spring
목차
  1.  
  2. 1.UriComponentsBuilder  사용하기 Http 형식의 Get 방식이라고 생각하시면돼요
  3. 예를들어
  4. 제 사이트를 기준으로 말씀드리면 
  5.  
  6.  
  7. 기존방식 ::: == >    https://serverrefository.tistory.com  
  8.  
  9. UriComponentsBuilder.newInstance() 방식 == > https://serverrefository.tistory.com?hi=안녕&바이=가라
  10.  
  11. 이런식으로 되는거죠
  12. ?hi=안녕&바이=가라   == < 이부분이 새로 생성되는거에요

 

 

 

1.UriComponentsBuilder  사용하기 Http 형식의 Get 방식이라고 생각하시면돼요

package com.example.spring08.controller;

import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

public class test2 {

	public static void main(String[] args) {

		
		
		
		UriComponents uri11= UriComponentsBuilder.newInstance()
				.queryParam("hi", "안녕")
				.queryParam("바이", "가라")
				.build();
		
		System.out.println(uri11.toString());
	}

}

 

 

UriComponentsBuilder.newInstance() 를사용하기 되면 

 

예를들어

제 사이트를 기준으로 말씀드리면 

 

 

기존방식 ::: == >    https://serverrefository.tistory.com  

 

UriComponentsBuilder.newInstance() 방식 == > https://serverrefository.tistory.com?hi=안녕&바이=가라

 

이런식으로 되는거죠

 

 

?hi=안녕&바이=가라   == < 이부분이 새로 생성되는거에요

 

 

2. toString() 안써도 정상적으로 나타나요

 

package com.example.spring08.controller;

import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

public class test2 {

	public static void main(String[] args) {

		
		
		
		UriComponents uri11= UriComponentsBuilder.newInstance()
				.queryParam("hi", "안녕")
				.queryParam("바이", "가라")
				.build();
		
		System.out.println(uri11);
	}

}

저작자표시 (새창열림)

'기존 > 🏀Spring' 카테고리의 다른 글

[스프링부트] 스프링 국제화 웹애플리케이션 구현 (영어)  (0) 2022.10.29
[스프링부트] 스프링 메시지 소스 웹애플리케이션 구현  (0) 2022.10.29
[Spring][상품 프로젝트][2] web.xml 한글처리 인코딩 UTF-8  (0) 2022.07.25
[Spring][상품 프로젝트][1] pom.xml 설정  (0) 2022.07.25
[스프링-9]Spring 다음 주소록 api 구현하기  (0) 2022.07.15
  1.  
  2. 1.UriComponentsBuilder  사용하기 Http 형식의 Get 방식이라고 생각하시면돼요
  3. 예를들어
  4. 제 사이트를 기준으로 말씀드리면 
  5.  
  6.  
  7. 기존방식 ::: == >    https://serverrefository.tistory.com  
  8.  
  9. UriComponentsBuilder.newInstance() 방식 == > https://serverrefository.tistory.com?hi=안녕&바이=가라
  10.  
  11. 이런식으로 되는거죠
  12. ?hi=안녕&바이=가라   == < 이부분이 새로 생성되는거에요
'기존(310)/🏀Spring' 카테고리의 다른 글
  • [스프링부트] 스프링 국제화 웹애플리케이션 구현 (영어)
  • [스프링부트] 스프링 메시지 소스 웹애플리케이션 구현
  • [Spring][상품 프로젝트][2] web.xml 한글처리 인코딩 UTF-8
  • [Spring][상품 프로젝트][1] pom.xml 설정
조각남자
조각남자
프로그래밍 기술 및 저장소
조각남자
조각남자
조각남자
전체
오늘
어제
  • 전체 보기
    • Java
      • Spring
    • 기존
      • 🏀Jsp
      • 🏀Spring
      • 🏀Pom.xml
      • 🏀SpringBoot
      • 🏀JavaExcption
      • 🏀JavaDB
      • 🏀SpringBootCloneWebSite
      • 🏀SptringDependency
      • 🏀JpaEnvorinoment
      • 🏀Thymeleaf
      • 🏀Node
      • 🏀Pyton
      • 🏀DataBase
      • 🏀JavaScript
      • 🏀Android
      • 🏀JPA
      • 🏀Flutter
      • 🐸Utils
      • 🎫 Batch
      • 🎞️JenKins
      • 🎈Python
      • 🎗️AWS
      • 🦠Vue
      • 🐳React
      • 🖲️kafka
      • Next.js

공지사항

  • 공지사항

인기 글

태그

  • D

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.1
조각남자
[스프링] UriComponentsBuilder 사용하기
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.