๐Ÿ“ ๊ธฐ๋ก/๐Ÿ–๏ธ Error Note

Java/Spring | Unknown return value type: java.lang.Integer

  • -

Error

Unknown return value type [java.lang.Integer]

Java ์„œ๋ฒ„์™€ Ajax ํ˜ธ์ถœ ์‹œ ์—๋Ÿฌ

 

Solution Content

@ResponsBody ๋ˆ„๋ฝ
: ๋ฆฌํ„ด๋˜๋Š” ๊ฐ’์€ view ๋ฅผ ํ†ตํ•ด์„œ ์ถœ๋ ฅ๋˜์ง€ ์•Š๊ณ  HTTP ResponseBody ์— ์ง์ ‘ ์“ฐ์—ฌ์ง€๊ฒŒ ๋จ.

 

Before

@RequestMapping(value = "/test.do", method = RequestMethod.POST)
public int test(HttpServletRequest request, @ModelAttribute VO vo) throws Exception {
    int testCnt = testService.testCnt(vo);
    
    return testCnt;
}

 

After

@ResponseBody
@RequestMapping(value = "/test.do", method = RequestMethod.POST)
public int test(HttpServletRequest request, @ModelAttribute VO vo) throws Exception {
    int testCnt = testService.testCnt(vo);
    
    return testCnt;
}
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.