The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this ap

代码:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<body bgcolor="white">
    <jsp:useBean id="clock" class="java.util.Date" />
<c:choose>
<c:when test="${clock.hours < 12}">
    <h1>Good morning!</h1>
</c:when>
<c:when test="${clock.hours < 18}">
   <h1>Good day!</h1>
</c:when>
<c:otherwise>
<h1>Good evening!</h1>
</c:otherwise>
</c:choose>
Welcome to our site, open 24 hours a day.

 

正常情况:
运行时会根据当时的时间 clock.hours 来判断当前时间,以便输出不同语句,早上输出Good morning! 中午输出 Good day! 晚上输出Good evening!
如:
Good morning!
Welcome to our site, open 24 hours a day.

问题:
第三行: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
总是报错如下:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
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

在这里先解释一下uri(Uniform Resoure Identifier):用来标识库的位置的.
错误说:uri不能在web.xml或jar文件中被解析.
由于这时致命错误(fatal error)程序无法被执行.
如果去掉这一行,程序就找不到jstl库,编译能通过,也能执行,但是所有的jstl组建都失效
运行结果会这样:
Good morning!
Good day!
Good evening!
Welcome to our site, open 24 hours a day.
这显然时不对的.

解决方案:
我注意到在第三行的上放有一段自动生成的注释:
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
如果要用到jstl的话要在工程视图的库接点上添加JSTL 1.1库.
展开工程视图中当前工程 -> 右键"库"接点 -> 添加库 -> JSTL 1.1 -> 确认
然后在重新执行就OK了
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值