pom.xml
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.7.3</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.7.3</version> </dependency>
Controller
@RequestMapping(value="/replies/all/{bno}", method = RequestMethod.GET) public ResponseEntity<List<ReplyDTO>> list(@PathVariable("bno") int bno){ ResponseEntity<List<ReplyDTO>> entity = null; try { entity = new ResponseEntity<>(service.list(bno), HttpStatus.OK); } catch (Exception e) { e.printStackTrace(); entity = new ResponseEntity<>(HttpStatus.BAD_REQUEST); } return entity; }
jsp파일
var bno = 73786; $.getJSON("/replies/all/" + bno, function(data){ var str = ""; $(data).each( function(){ str += "<li data-rno='" + this.rno + "' class='replyLi'>" + this.rno + " : " + this.replytext + "</li>"; } ); $("#replices").html(str); });