學習JSP遇到的問題 ---標準標誌庫

來源:互聯網
上載者:User
js|標準|問題  

我剛剛開始學習JSP  ,最近看到了標準標誌庫這一節,問題還真的不少,在CSDN上發布了一下我的疑問,居然只有一個人回複。暈。 

現在再說這兩個問題吧:

我的環境是  Eclipse 3.1  + jdk1.5 + tomcat 5

1.xmlbuddy_2.0.56總是裝不上。   在單位和家,一樣的開發環境(我保證完全一樣,我用的相同的安裝程式),在單位就一下子成功了。在家就一直不成功。  鬱悶。我以為是xmlbuddy_2.0.56.的版本不對,換了N個還是不可以。

2.使用標準標誌庫後,總出現這樣的問題JSP Parsing Error:The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application. 相同的兩個JSP檔案有的時候卻沒有這種問題  老外的一些網站說,這是TOMCAT的servlet-api.jar有和。。。的有衝突(好像是這個檔案),事實上我覺得不像。我給大家看我的兩個例子吧:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page contentType="text/html; charset=gb2312" language="java" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<jsp:useBean id = "cal" class="jstlTest.CalendarBean"/>

<html>
<head>
<title>測試網頁</title>
</head>
<body>
 
 The time is currently:<br><br>
 <c:out value = "${cal.date}"/>

 <c:set var ="hour" value = "${cal.hour}"  scope = "request"/>

<c:choose>
 <c:when test = "${hour >0 && hour <= 11}">
  Good  Morning!
 </c:when>

 <c:when test = "${hour >=12 && hour <= 17}">
  Good  Afternoon!
 </c:when>

 <c:otherwise>
  Good  Evening!
 </c:otherwise>

</c:choose>
</body>
</html>

這個檔案沒有任何問題。但是看下一:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html; charset=gb2312" language="java"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<fmt:setLocale value = "en_US"/>

<jsp:useBean id = "cal" class="jstlTest.CalendarBean"/>

<html>
<head>
<title>測試網頁</title>
</head>
<body>
 
 The time is currently:<br><br>
 <c:out value = "${cal.date}"/>

 <c:set var ="hour" value = "${cal.hour}"  scope = "request"/>

 <c:if test = "${hour >0 && hour <= 11}">
  Good  Morning!
 </c:if>

 <c:if test = "${hour >=12 && hour <= 17}">
  Good  Afternoon!
 </c:if>

 <c:if test = "${hour >=18}">
  Good  Evening!
 </c:if>

    <c:out value = "${hour}"/>
</body>
</html>
這個頁面就會出現上面的問題.JSP Parsing Error:The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application.

3.關於標誌庫的XML部分。 頁面代碼如下:

<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

<c:import var="rssFeed" url="/jstlTest/book.xml"/>
<x:parse var="rss" xml="${rssFeed}"/>
<x:set select="$book/book/title" var="rss" scope="session" />
<b><x:out select="$rss"/></b><br>

出錯:Content is not allowed in prolog.

javax.servlet.ServletException: javax.servlet.jsp.JspException: Content is not allowed in prolog.
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:844)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
        org.apache.jsp.isJSTLxml_jsp._jspService(org.apache.jsp.isJSTLxml_jsp:91)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.xml.sax.SAXParseException: Content is not allowed in prolog.
        com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
        com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSource(ParseSupport.java:227)
        org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseInputSourceWithFilter(ParseSupport.java:193)
        org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseReaderWithFilter(ParseSupport.java:199)
        org.apache.taglibs.standard.tag.common.xml.ParseSupport.parseStringWithFilter(ParseSupport.java:206)
        org.apache.taglibs.standard.tag.common.xml.ParseSupport.doEndTag(ParseSupport.java:138)
        org.apache.jsp.isJSTLxml_jsp._jspx_meth_x_parse_0(org.apache.jsp.isJSTLxml_jsp:135)
        org.apache.jsp.isJSTLxml_jsp._jspService(org.apache.jsp.isJSTLxml_jsp:74)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

暈。

google上關於這個的也很少。

獨學真的很鬱悶。



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.