1

我在使用 customtag 时遇到问题,并且

这是我的标签日历

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>tagCalendar</shortname>
    <info>Custom Tag Visualizzazione Lista Calendari</info>
    <tag>
        <name>tagCalendar</name>
        <tagclass>it.postecom.postesalute.tag.TagCalendar</tagclass>
        <bodycontent>empty</bodycontent>
        <info>Custom Tag Visualizzazione Lista Calendari</info>
        <attribute>
            <name>pageRedirect</name>
            <required>true</required>
        </attribute>
        <attribute>
            <name>collectionCalendar</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute><attribute>
            <name>actionUrl</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>
</taglib>

这是我的 JSP 片段

<ct:tagCalendar actionUrl="<portlet:actionURL/>" pageRedirect="viewPage" collectionCalendar="<%=QueryCalendar.getUserCalendars(JodUtil.getToken(request))%>" />

和 TagCalendar.java 的 doStartTag 方法

    try {
        JspWriter out = pageContext.getOut();
        Iterator iter = collectionCalendar.iterator();
        ArrayList <JodBaseCalendar>userCalendarList = new ArrayList<JodBaseCalendar>();
        int cnt = 0;
        while (cnt <= 3) {
            userCalendarList.add((JodBaseCalendar) iter.next());
            cnt++;
        }



        out.println("<table>");
        for(JodBaseCalendar calendar:userCalendarList){
            out.println("<tr>");
            out.println("<a href='"+actionUrl +"?forwardTo="+pageRedirect+"&calendarId="+ calendar.getCalendarId()+"'>");
            out.println("["+calendar.getCalendarId()+" - "+calendar.getCalendarSubject()+"]");
            out.println("</a>");
            out.println("</tr>");

        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 

    return TagSupport.SKIP_BODY;

标签不会转换为动作,而是像字符串一样使用。

4

1 回答 1

0

我是这样解决的,在jsp页面中

 <portlet:defineObjects /> 

    <ct:tagCalendar actionUrl="<%= renderResponse.createActionURL().toString() %>" pageRedirect="indexTo" collectionCalendar="<%=QueryCalendar.getUserCalendars(JodUtil.getToken(request))%>" />
于 2013-01-31T08:27:02.437 回答