복붙노트

[SPRING] Spring의 요청 매개 변수에 특수 문자를 보내는 방법

SPRING

Spring의 요청 매개 변수에 특수 문자를 보내는 방법

요청 매개 변수에서 특수 문자를 처리하는 방법? 여기 내 컨트롤러가 있습니다 :

@Scope("request")
@RestController
public class GetOperatorSeries{
@RequestMapping(value = "test", method = RequestMethod.GET)
    public String getOperatorSeries(HttpServletResponse response, @RequestParam(value = "mobno") long mobno,
            @RequestParam(value = "sourceType") String sourceType,
            @RequestParam(value = "responseType") String responseType)
{

}

예를 들어 요청 매개 변수에 특수 문자를 사용하면 "sourceType = @ $ abc"를 보내는 것과 같이 읽지 않습니다. 그러면 null 또는 비어있는 것으로 읽습니다. 하지만 특수 문자도 읽어야합니다.

해결법

  1. ==============================

    1.요청 매개 변수를 인코딩해야합니다.

    요청 매개 변수를 인코딩해야합니다.

    목록에 대한 링크를 확인하십시오 : http://www.w3schools.com/tags/ref_urlencode.asp

    그리고 앞뒤로 변환이 : http://meyerweb.com/eric/tools/dencoder/

  2. from https://stackoverflow.com/questions/35992342/how-to-send-special-characters-in-request-parameters-in-spring by cc-by-sa and MIT license