简体   繁体   中英

How to use jstl/functions and jstl/fmt in the same JSP

i imported the two libraries jstl/functions and jstl/fmt in my JSP as follows:

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

i attempt to use these 2 libraries for formatting date, get length of string i have a problem when i run the page, the problem is:

 org.apache.jasper.JasperException: Attempt to redefine the prefix fn to    
 http://java.sun.com/jsp/jstl/functions, when it was already defined as     
 http://java.sun.com/jsp/jstl/fn in the current scope

i tried to remove one and try to use its prefix instead of the other but it fails also, what is the main cause of that:

The only time I encounter this issue is when I have both taglibs set with the prefix "fn", like this:

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

You clearly don't have this in your example, however I would venture a guess that you had it this way at some point and compiled the jsp. Now that you have fixed the issue, the page/project may need to be recompiled.

I've also encountered Tomcat "holding" old versions if you don't explicitly undeploy the application. This can be done in Netbeans by going to Services->Servers->{your tomcat instance}->Web Applications->{right click application name}->undeploy

You can also remove it from the Tomcat folder in the work directory and web apps folder to accomplish the same thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM