解决:The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml...

今天在运行Web应用的时候,又遇到了之前遇到的错误,一时间又忘记了解决的办法,所以还是花一些时间记录下来流程吧。具体的现象是这样的:一个Web应用,包含JSP页面,使用到了JSTL标签库。在启动之后,报错:

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

解决:The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml..._第1张图片

在网上查看解决办法,大多数是说因为导入的包版本问题,但是按照他们的解决方式进行处理,并不奏效。针对这一问题,我个人使用的解决办法如下:

比如我在JSP页面中使用到了下面这两个标签库,然后报错:

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

可以在web.xml中,为web-app标签添加子标签jsp-config添加如下的配置:

<jsp-config>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
      <taglib-location>/WEB-INF/fmt.tld</taglib-location>
    </taglib>
  </jsp-config>

taglib-location标签指向了一个具体的文件,这个文件可以在standard.jar中找到,将其置于一个指定目录即可(这里我放在了WEB-INF下)

你可能感兴趣的:(JavaWeb)