동기증명
-
Ajax 사용, DB 읽어와서 웹브라우저에 보이기(레거시 방식 jsp)Front/js 2024. 7. 10. 14:25
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스 ✔ DB연결DB에 있는 데이터를 web브라우저에 보이려고 한다.DB의 데이터를 가져오기 위해서는 jsp를 사용해야한다. 데이터 테이블은 아래와 같다. ⌨ jsp 파일JDBC로 연결{"sangpum":[]}jsp는 안에 java를 사용한다.그 밖은 html소스를 사용한다. 위의 코드는 java를 사용해서 DB를 연결하는 코드이다.우선 프린트가 잘되는지 확인해보기위해 out.print(rs.getString("sang"));이 코드를 찍어봤다. 데이터베이스와 잘 연결되었음을 알 수 있다. 그럼 각 데이터를 추출해보자. String result = ""; while(rs.next()){ result +="{"; re..