2024-12-30



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script type="text/javascript">
$(function(){
$.ajax({
type : "post",
url : "data/book.xml",
dataType : "xml",
success : function(result) {
$(result).find("book").each(function() {
let title = $("title", this).text();
let author = $("author", this).text();
let price = $("price", this).text();
let txt = "<li>책 제목 : " + title + "</li>" +
"<li>책 저자 : " + author + "</li>" +
"<li>책 가격 : " + price + "</li><hr>";
$(".display").append(txt);
});
},
error : function() {
alert('통신오류 입니다!!!')
}
});
});
</script>
</head>
<body>
<div align="center">
<br> <br>
<h2>BOOK 리스트</h2>
<div class="display"></div>
</div>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<title>혼자 공부하는 자바</title>
<author>신용권</author>
<price>28,000원</price>
</book>
<book>
<title>Do it! mySQL로 배우는 데이터베이스 입문</title>
<author>강성욱</author>
<price>25,000원</price>
</book>
<book>
<title>Do it! HTML + CSS3 웹 표준의 정석</title>
<author>고경희</author>
<price>26,000원</price>
</book>
<book>
<title>최범균의 JSP 2.3 웹 프로그래밍</title>
<author>최범균</author>
<price>27,000원</price>
</book>
<book>
<title>코드로 배우는 스프링 웹 프로젝트</title>
<author>구멍가게 코딩단</author>
<price>38,000원</price>
</book>
</books>'JSP > 기초 내용 정리' 카테고리의 다른 글
| JSP(Ajax)_04 (0) | 2024.12.31 |
|---|---|
| JSP(Ajax)_03 (0) | 2024.12.31 |
| JSP(Ajax)_01 (0) | 2024.12.31 |
| JSP(Ajax)_00 (1) | 2024.12.31 |
| JSP(Example)_FileUpload (1) | 2024.12.27 |