问题
I'm getting following error when invoking my testtag.jsp:
org.apache.jasper.JasperException: Unable to convert string "<c:out var='myvar'/>" to class "javax.servlet.jsp.tagext.JspFragment" for attribute "att1": Property Editor not registered with the PropertyEditorManager
(The detailed stack trace is irrelevant)
I'm using a J2EE 1.4 server (that is, JSP 2.0)
My WEB-INF/testtag.tag
<%@ tag body-content="scriptless" %>
<%@ tag description="Renders some test html" %>
<%@ attribute name="att1" fragment="true" required="true" %>
<h1><jsp:invoke fragment="att1"/></h1>
The jsp testtag.jsp using this tag:
<%@page contentType ="text/html" pageEncoding="UTF-8" buffer="none" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<c:set var="myvar" value="hello world"/>
<t:testtag att1="<c:out var='myvar'/>" />
回答1:
According to JSP.7.1.6 of the JSP 2.0 specs (bold emphasis mine),
During the translation phase, various pieces of the page are translated into implementations of the
javax.servlet.jsp.tagext.JspFragmentabstract class, before being passed to a tag handler. This is done automatically for any JSP code in the body of a named attribute (one that is defined by<jsp:attribute>) that is declared to be a fragment, or of typeJspFragment, in the TLD.
That is, in testtag.jsp the fragment should be passed this other way:
<%@page contentType ="text/html" pageEncoding="UTF-8" buffer="none" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<c:set var="myvar" value="hello world"/>
<t:testtag>
<jsp:attribute name="att1"><c:out value='${myvar}'/></jsp:attribute>
</t:testtag>
来源:https://stackoverflow.com/questions/12623908/property-editor-not-registered-with-the-propertyeditormanager-error-on-custom-t