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上关于这个的也很少。
独学真的很郁闷。
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索java
, jsp问题
, servlet
, apache
, service
, httpservlet
, jasper问题
, jasper
, saxparseexception
, core java关于java问题
, 91jsp
, jasper pdf
jspservlet实现上传
,以便于您获取更多的相关知识。