问题描述
我需要一些帮助,我想做一个程序,并使用
i need some help, i wanted to do a program and used
if(session.getAttribute("logged")!="1"){
String err="You must be logged in!!";
request.setAttribute( "error", err );
String nextJSP = "/login.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response); }
%>
在jsp但是我的老板告诉我要使用jstl,所以我把它改成了:
In a jsp, but my boss told me to use jstl So i changed it to:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<c:if test="${session.getAttribute('logged')!=null}">
<jsp:forward page="login.jsp">
</jsp:forward>
</c:if>
<c:if test="${session.getAttribute('logged')==null}">
<jsp:forward page="princ.jsp"> </jsp:forward>
</c:if>
我得到一个讨厌的错误:
And i get a nasty error:
"org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application "
我在互联网上搜索了一些修复程序,我把javax.servlet.jsp .jstl-api-1.2.1-javadoc.jar在我的库中,甚至把javaee.jar放在Tomcat库中,但是还没有解决这个问题,有人可以帮我吗?
PS:我有Web开发人员的Eclipse Java EE IDE(INDIGO)Tomcat 7.08
I searched the internet for some fixes, i've put the javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar in my library, even put javaee.jar in the Tomcat library, but still got no solution to this, can somebody help me please?PS: i got Eclipse Java EE IDE for Web Developers.(INDIGO) Tomcat 7.08
推荐答案
您的taglib URI是
Your taglib URI is wrong.
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
此URI来自旧的和EOL的JSTL 1.0库。自JSTL 1.1起,由于EL部分从JSTL移动到JSP,因此taglib的内部工作已更改,因此您需要额外的 / jsp
。
This URI is from the old and EOL'ed JSTL 1.0 library. Since JSTL 1.1, you need an extra /jsp
in the path because the taglib's internal workings were changed because the EL part was moved from JSTL to JSP:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
此外,您试图放入 / WEB-INF中的JAR文件/ lib
是错误的。 javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar
只包含JSTL javadocs和 javaee.jar
包含整个Java EE API,可能是desastreus,因为Tomcat已经部署了它(JSP / Servlet),它可能是。
Further, the JAR files which you attempted to drop in /WEB-INF/lib
are wrong. The javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar
is contains only the JSTL javadocs and the javaee.jar
contains the entire Java EE API which may be desastreus because Tomcat ships with parts of it already (JSP/Servlet) which may conflict.
全部删除它们。您需要文件。
Remove them all. You need the jstl-1.2.jar file.
- Our JSTL tag wiki page
这篇关于绝对uri:http://java.sun.com/jstl/core无法在web.xml或与此应用程序一起部署的jar文件中解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!