Issue with uri of custom tag library

I have seen a weird problem while using custom tag libraries. In one of my jsp pages the relative uri path of the custom tld file is wrong.

Taglib is included in jsp page like below <%@ taglib prefix="aaa" uri="WEB-INF/bbb.tld" %> Location of bbb.tld is : StoresWebContentWEB-INFbbb.tld

This taglib is included in a parent jsp file, and not there jsp file is imported/included from parent.

My application has several other jsp files, where the same taglib is used with the correct path.

The same code is deployed in multiple test environments. In a few environments the code is throwing an error of "Failed to find resource", which is expected. But the taglib is working fine in most of the environments, instead of wrong path.

Why is there discrepancy in the behavior between different server environments? Does the server automatically look for all tld files if the uri can't be resolved?


I would recommend adding a trailing slash ('/') before WEB-INF. Could you try the following?

<%@ taglib prefix="aaa" uri="/WEB-INF/bbb.tld" %>

Hopefully, this will give you consistent results across all you server instances. Also, having your TLD in StoresWebContentWEB-INFbbb.tld seems to be related to be using an IDE (eg Eclipse) to develop your application. Once you export your application as an EAR or WAR the path will look more like Stores.war/WEB-INF/bbb.tld

链接地址: http://www.djcxy.com/p/74674.html

上一篇: JSTL 1.2绝对的uri:http://java.sun.com/jsp/jstl/core无法解析

下一篇: 问题与自定义标签库的URI