我正在关注JSP教程,并在JSP页面中介绍了有关XML解析的章节。本教程不使用Eclipse,但我将Tomcat 8作为服务器导入。下面的示例显示了XML文件的URL,但是我将books.xml文件放在eclipse中,或者如何配置eclipse来查找它?
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL x:parse Tags</title>
</head>
<body>
<h3>CH24 XML Parse Books Info:</h3>
<c:import var="bookInfo" url="http://localhost:8081/books.xml" />
<x:parse xml="${bookInfo}" var="output" />
<b>The title of the first book is</b>:
<x:out select="$output/books/book[1]/name" />
<br>
<b>The price of the second book is</b>:
<x:out select="$output/books/book[2]/price" />
</body>
</html>