JSP 2 tag files “/WEB-INF/tags” not found

…衆ロ難τιáo~ 提交于 2019-12-07 19:34:46

问题


I want to write some jsp tag files for my application. I followed this article: http://www.techrepublic.com/article/an-introduction-to-jsp-20s-tag-files/

However, I'm stuck, when I open a jsp page that has this line:

<%@ taglib prefix="h" uri="/WEB-INF/tags"%>

I get an exception.

HTTP Status 500 - /test.jsp (line: 8, column: 41) File "/WEB-INF/tags" not found
org.apache.jasper.JasperException: /test.jsp (line: 8, column: 41) File "/WEB-INF/tags" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)

If I refresh the page, sometimes I got a different page:

HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.test_jsp
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.test_jsp

All I did was, in eclipse I created a folder called "tags" in WebContent/WEB-INF. I created a tag file, "email.tag" , with the following content:

<%@ tag language="java" pageEncoding="ISO-8859-1"%>
<%@ attribute name="email" required="true" %>
<%
    String emailOutput = "<a href=\"mailto:{$email}\">${email}</a>";
%>
<%=emailOutput %>

Eclipse autocomplete recognizes, and suggests this:

<h:email email=""></h:email>

I use Tomcat7. I tried to search for this error on google and here, but could not find an answer. What am I missing?


回答1:


That's not how tag files must be used. The correct syntax is

<%@ taglib tagdir="/WEB-INF/tags" prefix="h" %>

See http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPTags5.html



来源:https://stackoverflow.com/questions/20586026/jsp-2-tag-files-web-inf-tags-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!