티스토리 뷰

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
 
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.8.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.8.1</version>
        </dependency>
cs


pom에 기본적으로 추가 


1
2
3
4
5
6
    @RequestMapping(value = "/html/test3json", method = RequestMethod.POST, produces = "application/json" )
    public String test03post(@RequestBody Map<String, Object> jsons) {
        System.out.println(jsons);
        
        return "./html/test3";
    }
cs


RequestBody를 꼭 써야 한다. 그래야 받은 텍스트 전채를 인식한다. 

위는 Map형식으로 String으로 인식하는 방법은 


1
2
3
4
5
6
    @RequestMapping(value = "/html/test3json", method = RequestMethod.POST, produces = "application/json" )
    public String test03postString(@RequestBody String jsons) {
        System.out.println(jsons);
        
        return "./html/test3";
    }
cs



Map을 String으로 고치면 된다. 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
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
31
글 보관함