how to access my custom jsp taglib in STS 4.3?
I have a Spring MVC web app whic I'm developing using the STS 4.3 as my IDE.
I decided to try my hand on custom JSP tag libraries.
These are the tutorial I'm following: http://www.tutorialspoint.com/jsp/jsp_custom_tags.htm and http://www.noppanit.com/how-to-create-a-custom-function-for-jstl/ and http://blog.denevell.org/tomcat7-el-custom-function.html and many other links (too many to list but similar in content).
I have configured Tomcat7 as my testing server from with STS 4.3
I have created a new project in STS and called it "MyCustomUtilities".
folder structure of MyCustomUtilities project : http://i.imgur.com/9nEuPYW.jpg
source code for MyCustomUtilities.java
package org.flinders.mycustomutilities;
import java.lang.StringBuilder;
public class MyCustomUtilities {
public static String StringToHTML(String inputString) {
StringBuilder returnString = new StringBuilder();
char[] inputChar = inputString.toCharArray();
for (char c: inputChar) {
returnString.append("&#").append((int) c).append(";");
}
return returnString.toString();
}
}
JSP snippet (I've also tried <%@ taglib uri="WEB-INF/MyCustomUtilities.tld" prefix="mine" %> but still getting error)
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://localhost:8080/MyCustomUtilities.tld" prefix="mine" %>
Tomcat folder structure: http://i.imgur.com/oT3Ndhp.jpg
I have created a system variable called "CLASSPATH" and it's pointing to the ROOT/WEB-INF (full path of course. just shorten it here).
here's my TLD file (unsure on what to put on the uri portion but I'm accessing my web app on localhost:8080 on my browser)
<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.1">
<tlib-version>2.0</tlib-version>
<uri>localhost:8080/MyCustomUtilities</uri>
<function>
<name>StringToHTML</name>
<function-class>org.flinders.mycustomutilties.MyCustomUtilities</function-class>
<function-signature>java.lang.String StringToHTML(java.lang.String)</function-signature>
</function>
</taglib>
Any ideas on how can I setup/configured tomcat/STS so it can see my custom tag library? As I said above, I'm looked at various examples but they don't seem complete. thanks
链接地址: http://www.djcxy.com/p/74682.html