属性编辑器未在PropertyEditorManager中注册:自定义标记调用时出错 [英] Property Editor not registered with the PropertyEditorManager: error on custom tag invokation

查看:1776
本文介绍了属性编辑器未在PropertyEditorManager中注册:自定义标记调用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调用 testtag.jsp 时遇到以下错误:

I'm getting following error when invoking my testtag.jsp:


org.apache.jasper.JasperException:无法将字符串< c:out var ='myvar'/>转换为属性att1的类javax.servlet.jsp.tagext.JspFragment:属性编辑器未注册使用PropertyEditorManager

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使用J2EE 1.4服务器(即JSP 2.0)

I'm using a J2EE 1.4 server (that is, JSP 2.0)

我的 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>

使用此标签的jsp testtag.jsp

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'/>" />


推荐答案

根据<7的JSP.7.1.6 href =http://download.oracle.com/otndocs/jcp/jsp-2.0-fr-oth-JSpec/ =nofollowtitle =JSP 2.0 Spec> JSP 2.0规范(粗体强调我的,


在翻译阶段,页面的各个部分被翻译成<$ c $的
实现c> javax.servlet.jsp.tagext.JspFragment 抽象类,在
传递给标记处理程序之前。对于命名属性(由< jsp:attribute> ; )在TLD中声明为
的片段,或者类型为 JspFragment

During the translation phase, various pieces of the page are translated into implementations of the javax.servlet.jsp.tagext.JspFragment abstract 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 type JspFragment, in the TLD.

也就是说,在 testtag.jsp 中,片段应该通过其他方式传递:

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>

这篇关于属性编辑器未在PropertyEditorManager中注册:自定义标记调用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆